src/main/android/SDL_android_main.c
author Eric Wing <ewing . public |-at-| gmail . com>
Mon, 22 Jul 2013 02:51:45 -0700
changeset 7501 b27825bb5879
parent 7467 src/main/android/SDL_android_main.cpp@998579383ced
child 7663 53fe1b64eb2d
permissions -rw-r--r--
Android: Removed all unnecessary dependencies on C++.

C++ is a bit of a minefield on Android. Much functionality still doesn't work, and Android can't decide on which C++ standard library to use, so it provides 3 different ones, all of which are incompatible with each other. (It looks like clang is coming too which will add a new compiler and a 4th standard library.)

As middleware, SDL might be distributed as a binary and intermixed with other projects already using C++. If C++ is intermixed in a bad way, bad things will happen. Removing dependencies on C++ will avoid this problem and downstream users won't have to worry/care.
     1 
     2 #include "SDL_config.h"
     3 
     4 #ifdef __ANDROID__
     5 
     6 /* Include the SDL main definition header */
     7 #include "SDL_main.h"
     8 
     9 /*******************************************************************************
    10                  Functions called by JNI
    11 *******************************************************************************/
    12 #include <jni.h>
    13 
    14 // Called before SDL_main() to initialize JNI bindings in SDL library
    15 extern void SDL_Android_Init(JNIEnv* env, jclass cls);
    16 
    17 // Start up the SDL app
    18 void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj)
    19 {
    20     /* This interface could expand with ABI negotiation, calbacks, etc. */
    21     SDL_Android_Init(env, cls);
    22 
    23     SDL_SetMainReady();
    24 
    25     /* Run the application code! */
    26     int status;
    27     char *argv[2];
    28     argv[0] = SDL_strdup("SDL_app");
    29     argv[1] = NULL;
    30     status = SDL_main(1, argv);
    31 
    32     /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
    33     //exit(status);
    34 }
    35 
    36 #endif /* __ANDROID__ */
    37 
    38 /* vi: set ts=4 sw=4 expandtab: */