| Issue 201: | "#include" not generated for extern class | |
| 1 person starred this issue and may be notified of changes. | Back to list |
The cpp "#include" code is not generated for included extern class.
Here is an example that results in cpp compiler error "In file included from ./src/Test.cpp:4: include/Test.h:31: error: ‘R’ does not name a type".
//-----------------------------------
//Test.hx
class Test {
var r:R;
static function main():Void {}
}
//-----------------------------------
//R.hx
extern class R {}
/**
* Real implementation of R.
*/
@:native("R")
class R_impl {}
Sep 25, 2012
I see! "@:include("R") extern class R {}" works for me!
Are there any other metadata that should be added to http://haxe.org/manual/tips_and_tricks ?
Oct 3, 2012
Hi, thinking about it again, would it be better to generate the include by default, and can be changed or opt-out with "@:include"? So that it will work just like the other targets without adding a hxcpp specific metadata.
Oct 4, 2012
Currently, the only uses for extern are some internal stuff, like int32 and FastIterator - these are provided by the runtime. Using externs for other stuff, you run into the problem of the include path - where are you expecting to find the external headers? I was thinking you might want @:include("/usr/something/include/R.h") or
@:include("sys/time.h") extern class timeval
I guess that cpp does not enforce the package/class structure like the other targets, and I the header-name-equals-class-name is far less common.
Feb 1, 2013
I'm closing this, unless you have a strong opinion on a use case.
Status:
WontFix
|
I have added two additional meta tags: @:depend and @:include The depend will add a dependency in the build.xml file - not so important. But you will need the @:include directive now: @:include("R.h") extern class R {} This allows you to not have an include file, or have it somewhere else.