Wrap C library in haxecpp?

Not to sound like a broken record on this forum, but you could try with ammer. :slight_smile:

The process for defining ammer definitions is fairly simple – you need to map the C types to the Haxe types you want. For most common cases, there is a 1-to-1 mapping (e.g. const char* is a String). You can also define data types that map to library-specific types in C, like the PrintConsole in your code example.

For your library, the definition might looks something like:

class Nx extends ammer.Library<"nx"> {
  // ...
}
@:ammer.struct // for alloc and free
class PrintConsole extends ammer.Pointer<"PrintConsole", Nx> {
  public function consoleInit(_:ammer.ffi.This):Void;
}
class Main {
  public static function main():Void {
    var console = PrintConsole.alloc();
    console.consoleInit();
    // ...
  }
}
-lib ammer
-D ammer.lib.nx.include=path/to/include/directory
-D ammer.lib.nx.library=path/to/lib/directory
-D ammer.lib.nx.headers=switch.h,nx.h,and_so_on.h
-main Main
-cpp out.cpp

(There is as of yet no way to create the type definitions automatically, since that would involve parsing the header files and essentially having a full C parser. Maybe one day.)

The manual should hopefully provide enough information.