ghc passing -undef to preprocessor and thereby eliminating OS specific defines

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ghc passing -undef to preprocessor and thereby eliminating OS specific defines

Nathan Hüsken
Hey,

I am trying to adapt some code in the libraries when compiling for
android (i.E. because some things are different on android to other
posix systems).

So in C code I would just do "#ifdef __ANDROID__".
While in the *.h and *.c files it seems to work, it does not work in
*.hs files.
I noted that the preprocessor is run like this:

arm-linux-androideabi-gcc -E -undef -traditional -fno-stack-protector
-DTABLES_NEXT_TO_CODE

The "-undef" parameter is causing the __ANDROID__ define to be removed.
Does it make sense to pass "-undef" to the preprocessor?

Any other Ideas how I could adapt the code for android?

Thanks!
Nathan


Reply | Threaded
Open this post in threaded view
|

ghc passing -undef to preprocessor and thereby eliminating OS specific defines

Simon Marlow-7
On 24/01/13 11:21, Nathan H?sken wrote:

> Hey,
>
> I am trying to adapt some code in the libraries when compiling for
> android (i.E. because some things are different on android to other
> posix systems).
>
> So in C code I would just do "#ifdef __ANDROID__".
> While in the *.h and *.c files it seems to work, it does not work in
> *.hs files.
> I noted that the preprocessor is run like this:
>
> arm-linux-androideabi-gcc -E -undef -traditional -fno-stack-protector
> -DTABLES_NEXT_TO_CODE
>
> The "-undef" parameter is causing the __ANDROID__ define to be removed.
> Does it make sense to pass "-undef" to the preprocessor?
>
> Any other Ideas how I could adapt the code for android?

You want to use:

   #ifdef android_HOST_OS

the *_HOST_OS symbol is defined by GHC when it ivokes CPP.

Cheers,
        Simon