HaxeFoundation / HaxeFoundation/hxcpp
cppia can't link extern abstract enum
- Dominant language
- C++
- Stars
- 330
- Forks
- 227
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 18
Description
Trying to use one from cppia results in an error like:
```
> ./host/Host script.cppia
in Script::0x7fffd27d7cb0
GetFieldByName at :0 main
Could not link static _Main.E_Impl_::N1 (3)
Error : Bad link
```
**n.hpp**
```
#pragma once
enum N {
N1 = 7,
N2 = -1
};
```
**Host.hx**
```
@:enum @:unreflective extern abstract E (EImpl) {
@:native("N1") var E1;
@:native("N2") var E2;
}
@:include("./n.hpp") @:unreflective @:native("N") extern class EImpl {}
class Host {
public static function main () {
trace(E.E1);
trace(E.E2);
}
}
```
**Script.hx**
```
class Script {
public static function main () {
Host.main();
trace(Host.E.E1);
trace(Host.E.E2);
}
}
```
Build the host `haxe -main cpp.cppia.Host -cpp host Host -D scriptable`, the script `haxe -main Script -cppia script.cppia` and run `./host/Host script.cppia`.
Using `-jit` doesn't change anything.
It can't access `_Main.E_Impl_::N1` since it's not in the host.
Sorry for the multi file example, couldn't figure out how to reduce to a single file.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.