Prev | Current Page 1020 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

Upon creating your new project, you will need to provide a reference to this file in the
projects makefile or compiler settings. You will also need to specify a reference to the neko.h header
file found in the Neko include directory, so that the functions and type definitions contained in the
library file can be validated at compile time.
A Simple Hello World Example
Okay, so a Hello World example might be a little too simple to be anything useful, especially to all the
hard - core C/C++ developers, but it will make a great starting point. Let ??™ s jump in to one such example,
now. Work through the following steps, producing a complete, albeit useless, Neko module. You ??™ ll get to
the part about how each fragment works afterward.
Building the ndll Library in C
The following code describes a standard Hello World example in C with the necessary commands
needed to make it Neko compatible:
#include ???neko.h???
#include < stdio.h >
value PrintHelloWorld()
{
printf( ???Hello, World!??? );
return val_null;
}
DEFINE_PRIM( PrintHelloWorld, 0 );
Chapter 20: Extending ha X e with C/C++
557
This is about as simple as it gets, and indeed, should closely resemble a Hello World example in any
C/C++ book.


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