HaxeFoundation / HaxeFoundation/haxe
@:include directive is being ignored on hxcpp target
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
There's something inconsistent or mysterious about how `@:include` works that's preventing it from doing anything at all. Another project where I am not doing anything substantially different is allowing it to work, although there I wasn't able to include the same .h file in multiple .hx files, forcing me to stuff everything related to a lib in the same file. Anyway, with this class:
```haxe
package grig.plugin.lv2; #if cpp
import cpp.ConstCharStar;
import cpp.RawPointer;
import cpp.Void;
import grig.plugin.Lib;
@:include('./lv2/lv2/core/lv2.h')
typedef LV2_Handle = RawPointer;
@:native('LV2_Feature*')
extern class LV2Feature
{
var URI:ConstCharStar;
var data:RawPointer;
}
@:native('const LV2_Descriptor*')
extern class LV2Descriptor
{
var URI:ConstCharStar;
}
typedef LV2DescriptorFunction = (Int)->LV2Descriptor;
class Instance
{
public var uri(default, null):String;
private function new()
{
}
public static function load(libName:String):Instance
{
var instance = new Instance();
var libHandle = new Lib(libName);
var lv2Descriptor:LV2DescriptorFunction = libHandle.loadSymbol('lv2_descriptor');
var descriptor = lv2Descriptor(0);
instance.uri = descriptor.URI.toString();
return instance;
}
}
#end
```
And this main.hx:
```haxe
package;
using grig.plugin.lv2.Instance;
class Main
{
static function main()
{
var instance = Instance.load('amp.so');
trace(instance.uri);
}
}
```
I get `error: ‘LV2_Descriptor’ does not name a type`, which would only happen if `lv2.h` wasn't include. Sure enough `grep -R lv2.h` reveals nothing in the generated cpp. It's being completely ignored.
Contributor guide
Assessment
This issue has not been assessed yet.