Here's my preprocessor section in my C++ code which I want to generate SWIG bindings.
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__FreeBSD_kernel__) \
|| defined(__OpenBSD__)
#include <machine/endian.h>
#endif
#if defined(__linux__) || defined(__CYGWIN__) || defined(__GNU__) || \
defined(ANDROID)
#include <endian.h>
#endif
#ifdef __MINGW32__
#include <sys/param.h>
#endif
#ifdef _MSC_VER
/* _MSVC lacks BYTE_ORDER and LITTLE_ENDIAN */
#define LITTLE_ENDIAN 0x0001
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN)
#error No byte order defined
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
# define HIOFFSET 1
# define LOWOFFSET 0
#else
# define HIOFFSET 0 /* word offset to find MSB */
# define LOWOFFSET 1 /* word offset to find LSB */
#endif
But when I try to generate SWIG bindings using the swig
command, I get the following error:
Error: CPP #error "No byte order defined". Use the -cpperraswarn option to continue swig processing.
It seems when SWIG tries to generate the bindings, <machine/endian.h>
is not being included for some reasons.
How can I fix this error? Do I need to add anything to the SWIG interface file?
I'm using macOS 10.14.4.
ADDED: Here's what my SWIG interface file looks like.
%module pd
%{
#include "myBindings.h"
%}
%include "myBindings.h"
As you can see there's nothing special in it.
And I generate the bindings using the following command:
swig -c++ -lua -fcompact -fvirtual -I../../../libs/openFrameworks myBindings.i && mv myBindings_wrap.cxx myBindings.cpp
Then I get the above mentioned error.
Even when I just leave #include <machine/endian.h>
it still generates the same error. (No byte order defined
)