HXCPP best way to extern c code?

81 views
Skip to first unread message

Josh Brown

unread,
Aug 28, 2016, 1:13:04 AM8/28/16
to Haxe
Hello!

I'm writing some externs and have run into some trouble interfacing with some C code.

Let's say I have a library imported with 
#include <mylibrary.h>

and it provides definitions for the following functions and types TYPE_A, TYPE_B;
void functionA();
void functionB();

What would be the best way to write externs for this C code? It's not namespaced and I cannot use the @:native metadata as it prepends ::_obj:: if you supply an empty string (e.g @:native("") )

Valentin Lemière

unread,
Aug 28, 2016, 1:19:56 PM8/28/16
to Haxe
Hi,

this should work:
@:include("mylibrary.h")
extern class MyExtern {
 
@:native("functionA") public static function functionA():Void;
 
@:native("functionB") public static function functionB():Void;
}

@:native("TYPE_A")
extern class TypeA {
}

Josh Brown

unread,
Aug 28, 2016, 7:26:20 PM8/28/16
to Haxe
Perfect, that works beautifully!
Reply all
Reply to author
Forward
0 new messages