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.
slouken@6044
     1
slouken@6044
     2
#include "SDL_config.h"
slouken@6044
     3
slouken@6044
     4
#ifdef __ANDROID__
slouken@4964
     5
slouken@4964
     6
/* Include the SDL main definition header */
slouken@4964
     7
#include "SDL_main.h"
slouken@4964
     8
slouken@4964
     9
/*******************************************************************************
slouken@4964
    10
                 Functions called by JNI
slouken@4964
    11
*******************************************************************************/
slouken@4964
    12
#include <jni.h>
slouken@4964
    13
slouken@4964
    14
// Called before SDL_main() to initialize JNI bindings in SDL library
ewing@7501
    15
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
slouken@4964
    16
slouken@4964
    17
// Start up the SDL app
ewing@7501
    18
void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj)
slouken@4964
    19
{
slouken@4964
    20
    /* This interface could expand with ABI negotiation, calbacks, etc. */
slouken@4998
    21
    SDL_Android_Init(env, cls);
slouken@4964
    22
slouken@7281
    23
    SDL_SetMainReady();
slouken@7281
    24
slouken@4964
    25
    /* Run the application code! */
slouken@4999
    26
    int status;
slouken@4964
    27
    char *argv[2];
philipp@7467
    28
    argv[0] = SDL_strdup("SDL_app");
slouken@4964
    29
    argv[1] = NULL;
slouken@4999
    30
    status = SDL_main(1, argv);
slouken@4999
    31
slouken@6186
    32
    /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
slouken@6186
    33
    //exit(status);
slouken@4964
    34
}
slouken@4999
    35
slouken@6044
    36
#endif /* __ANDROID__ */
slouken@6044
    37
slouken@4999
    38
/* vi: set ts=4 sw=4 expandtab: */