Prev | Current Page 1021 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

Compile this as hello.ndll , and place the output file into the Neko directory. You can
now use this library from either a haXe script or a Neko script. If you want, you could instead place the
library in a working haXe directory for one of your projects. Either way, the Neko run time will be able
to locate the library and execute the specified function.
If you receive errors while compiling this code, be sure to check the references for the included directory
and the path to the Neko library file. This will usually form a majority of the issues found by developers
new to C/C++.
Building the ha X e Script
To access the PrintHelloWorld function in your library from within a haXe script, create a new haXe
file and enter the following:
class HelloWorld
{
public static function main()
{
hello();
}
static var hello = neko.Lib.load( ???hello???, ???PrintHelloWorld???, 0 );
}
Now, compile the haXe file and execute it from a command prompt. The script will run and immediately
exit, presenting the text:
> Hello, World!
The Post - Mortem
While this example doesn ??™ t demonstrate much of the Neko C foreign function interface, it does outline
its simplicity.


Pages:
1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033