Is there a way to declare an array of primitives (for cpp extern)? Unfortunately, haxe.ds.Vector doesnt work for some reason


(Dmitry) #1


Let’s say I have following C function: void log(char *line) // real native code and I couldn’t do anything about it
I need to pass – char buffer[1024] to it. How do I declare said buffer variable such that haxe would generate the right code?

I tried new Vector<Char>(1024) but it failed with casting error. Then I came up with helper:

class CharArray {
inline public static function create(size: Int32): RawPointer<Char> {
untyped __cpp__("char buffer[{0}]", size);
return untyped __cpp__("buffer");

It is working as expected but looks ugly. I think, there should be more elegant solution.