HaxeFoundation / HaxeFoundation/haxe
@:nativeGen cause compilation error on C++ target
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
``` haxe
@:nativeGen interface MyInterface {
function myMethod():Void;
}
@:nativeGen class MyClass implements MyInterface {
public function new() {}
public function myMethod():Void {}
}
class Main {
public static function main() {
var i:MyInterface = new MyClass();
i.myMethod();
}
}
```
```
$ haxe -version
3.2.1
$ haxe -cpp cpp -main Main.hx
haxelib run hxcpp Build.xml haxe -Dhaxe3="1" -Dhaxe_ver="3.201" -Dhxcpp_api_level="321" -I"/usr/lib/haxe/extraLibs/" -I"/usr/local/lib/haxe/extraLibs/" -I"" -I"/usr/lib/haxe/std/cpp/_std/" -I"/usr/share/haxe/std/cpp/_std/" -I"/usr/local/lib/haxe/std/cpp/_std/" -I"/usr/lib/haxe/std/" -I"/usr/share/haxe/std/" -I"/usr/local/lib/haxe/std/"
g++ -Iinclude -c -fvisibility=hidden -stdlib=libstdc++ -O2 -I/Users/twer/.haxelib-local/hxcpp/3,2,193/include -DHX_MACOS -m64 -Wno-parentheses -Wno-unused-value -Wno-format-extra-args -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=321 -x c++ -frtti -Wno-invalid-offsetof ./src/Std.cpp -o/private/tmp/nativeGen/cpp/obj/darwin64/ae7b103b_Std.o
g++ -Iinclude -c -fvisibility=hidden -stdlib=libstdc++ -O2 -I/Users/twer/.haxelib-local/hxcpp/3,2,193/include -DHX_MACOS -m64 -Wno-parentheses -Wno-unused-value -Wno-format-extra-args -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=321 -x c++ -frtti -Wno-invalid-offsetof ./src/Main.cpp -o/private/tmp/nativeGen/cpp/obj/darwin64/ae7b103b_Main.o
Error: ./src/Main.cpp:31:19: error: no member named 'MyClass_obj' in the global namespace; did you mean 'hx::Class_obj'?
::MyClass tmp = ::MyClass_obj::__new(); HX_STACK_VAR(tmp,"tmp");
^~~~~~~~~~~~~
hx::Class_obj
/Users/twer/.haxelib-local/hxcpp/3,2,193/include/hx/Class.h:90:37: note: 'hx::Class_obj' declared here
class HXCPP_EXTERN_CLASS_ATTRIBUTES Class_obj : public hx::Object
^
./src/Main.cpp:31:34: error: no member named '__new' in 'hx::Class_obj'
::MyClass tmp = ::MyClass_obj::__new(); HX_STACK_VAR(tmp,"tmp");
~~~~~~~~~~~~~~~^
./src/Main.cpp:33:17: error: variable type '::MyInterface' is an abstract class
::MyInterface i = tmp; HX_STACK_VAR(i,"i");
^
include/MyInterface.h:13:16: note: unimplemented pure virtual method 'myMethod' in 'MyInterface'
virtual Void myMethod( )=0;
^
3 errors generated.
Error: Build failed
```
Contributor guide
Assessment
This issue has not been assessed yet.