Preprocessor woes

Hi there!
I tried compiling Ogre for Android with the tools. Unfortunately the Ogre Source relies heavily on
if defined( WIN32 ) || defined( _WIN32 )

And stuff like that.

Is there a way to cheat the compiler into thinking the compiling system is an Android device?

Thanks in advance!

Hello Emerix,

I’m afraid that simple recompiling won’t help in your case. You may want to check this official Ogre 3D wiki article about running it on Android: [url]http://www.ogre3d.org/tikiwiki/Ogre+Android[/url]

Hi Dmitry,

That article is pretty outdated. Sadly, it still shows up during the google search.

As this article shows, getting Ogre to Android is very much possible, unfortunately that requires that whole cmake scripting and all that - which is all very unintuitive.
Basically the only thing holding me back, as far as I can judge now, is that the system sees me working on Windows instead of Android - and thus the preprocessor uses the wrong code.

I’d appreciate hints =)

Hello Emerix,

That’s strange. How do you compile your project? I have tried creating both MSBuild- and ndk-build-based Hello World projects to test for the defined macros like this:

jstring
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env, jobject thiz )
{
    return (*env)->NewStringUTF(env,
#if defined(__WIN32__) || defined(_WIN32)
        "Hello from WIN32 !"
#else
        "Hello from JNI !"
#endif
    );
}

But in both cases it displayed “Hello from JNI !”.

That is indeed strange!

It doesn’t work like that for me.

I created a new solution and an “Android Native Application”

When i add your lines to the android_main(…) function, it shows the android line greyed out.

Do I need a new version of the plugin or something?

Or is there some additional option I need to set?

EDIT:

Okay apparently it seems to do the right thing - but shows the wrong thing. When I compile with

#if defined(__WIN32__) || defined(_WIN32)
        "Hello from WIN32 !"
#else
        #error "Great goodness! We're in the right branch!"
#endif

it actually stops at the error.
Question is: Can we change the behaviour of what Visual Studio shows? Or is that a problem just I have with my German Windows and Visual Studio?

Hello Emerix,

I have the same problem with VS graying out wrong lines, I just forgot to mention it in my previous post. This may be fixed in the future.

Hey DmitryPolyanitsa,

Glad to hear I’m not the only one with that issue.

Hope we get some updates soon. It’s so much more fun to work with VS =)