Author Topic: Android Preprocessor ?  (Read 1689 times)

Offline mrplant

  • Mr. Polyvector
  • ***
  • Posts: 233
    • View Profile
Android Preprocessor ?
« on: 2012-Sep-07 »
I am having problems detecting Android platform.

It would be great, looking at documentation as it stands, if there was a defined pre-processor for android platforms.

Why is there no defined name for the Anroid platform?

I am running into complicated problems looking at Target$ isntead and trying to create a ?DEFINE myself but the code is being run even on say WIN32. argh...


Defined names
The following symbols are defined by the editor:
GLB_DEBUG Debug mode is active
GLB_VERSION The version number of the compiler
GLB_CONSOLE Program is a console program

WIN32 Current platform is: Win32
LINUX Linux x86
IPHONEiPhone, iPod Touch
WINCEWindows Mobile, Windows Phone, PocketPC
GP2XWIZGamepark Holding GP2X-Wiz
GP2XGamepark holding GP2X (F100, F200)
XBOXLINUXLinux x86, software renderer
CAANOOGPH Caanoo device


   ?ERROR Precprocessor not enabled ;)


     POLYVECTOR  0, 0, 0,0, 0xffffff
     POLYVECTOR  0,99, 0,0, 0xffffff
     POLYVECTOR 99,99, 0,0, 0xffffff
?ELSE // slow graphics ->
   DRRAWRECT 0,0,99,99, 0xffffff

Offline mrplant

  • Mr. Polyvector
  • ***
  • Posts: 233
    • View Profile
Re: Android Preprocessor ?
« Reply #1 on: 2012-Sep-07 »
MY game works on iOS, Osx, Win32, Android platforms and I coded this routine to detect and report back on platform info.

I set a preprocessor variable called ANDROID , if the android target is detected as there does not appear to be  a predefined one I could find documentation on.

Later on i test for IF defined (Android) ... do this code... etc.

My major problem is that the code below as it stands.. when I compile for windows - my game thinks it is running on Android and behaves accordingly.

In other words - the ANROID preprocessor variable is ALWAYS being defined..

How can I rewrite or work around this - I ideally want the game deciding on the platform rather than commenting or uncommenting a ?DEFINE ANDROID statement at the top of my code


//   Get Device Info

// This function gets more detailed device info.
// At the end of this function, Global Target$ will contain the text "PC", "IPHONE", "IPOD", "IPAD", "MAC" or "ANDROID", depending on device detected below. On Android, the ANDROID Preprocessor variable will also be created.

FUNCTION GetDeviceInfo:
   iPhoneVer = 0 // Reset iPhone specific version flag.
   Target$ = PLATFORMINFO$("") // Get the current Platform Info
   SELECT Target$
      CASE "WIN32"
         Target$ = "PC"
      CASE "IPHONE" // What type of iOS Device? Will return "iPhone", "iPod Touch", "iPad".
         Target$=UCASE$(PLATFORMINFO$("DEVICE")) // Get the Target Device Info. Make sure everything is in capitals for the ZX81 font!
         IF Target$="IPOD TOUCH"
            Target$="IPOD" // Device name too long so shorten it.
         IF Target$<>"IPAD"
            iPhoneVer = 1 // Set flag for iPhone or iPod touch models. This allows for onscreen buttons to be moved later etc.
         ?DEFINE ANDROID // Define the ANDROID Preprocessor variable.


  • Guest
Re: Android Preprocessor ?
« Reply #2 on: 2012-Sep-07 »
I use ?IF DEFINED(ANDROID) as it's a bit clearer.  However, currently stacked ?IF commands do have a slight problem in that all of them are checked even if the ?IF value is true.

It is fixed in the old/current/last beta though