We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3351

Summary: Some warnings compiling SDL_android_main.c
Product: SDL Reporter: Sylvain <sylvain.becker>
Component: mainAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: philipp.wiesemann
Version: 2.0.4   
Hardware: All   
OS: Android (All)   

Description Sylvain 2016-05-31 10:00:44 UTC
The file "SDL_android_main.c" has to be included in user's project, but it compiles with warnings.

The compilation does not depends on SDL warning flags, but on user's flags. 
Mines have "-Wundef" and "-Wmissing-prototypes"


Can be quickly solved by adding in the file "SDL_android_main.c".

#define TARGET_OS_IPHONE 0
#define __native_client__ 0
#define __EMSCRIPTEN__ 0
#define SDL_BUILDING_WINRT 0
#define __PSP__ 0
+ prototype of "nativeInit".

Or, there are probably better ways

Here's the log:



Compile thumb  : main <= SDL_android_main.c

In file included from src/main/android/SDL_android_main.c:4:
In file included from src/main/android/../../SDL_internal.h:24:

src/main/android/../../dynapi/SDL_dynapi.h:46:5: warning: 'TARGET_OS_IPHONE' is not defined, evaluates to 0 [-Wundef]
#if TARGET_OS_IPHONE || __native_client__ || __EMSCRIPTEN__  /* probably not useful on iOS, NACL or Emscripten. */
    ^

src/main/android/../../dynapi/SDL_dynapi.h:46:25: warning: '__native_client__' is not defined, evaluates to 0 [-Wundef]
#if TARGET_OS_IPHONE || __native_client__ || __EMSCRIPTEN__  /* probably not useful on iOS, NACL or Emscripten. */
                        ^
src/main/android/../../dynapi/SDL_dynapi.h:46:46: warning: '__EMSCRIPTEN__' is not defined, evaluates to 0 [-Wundef]
#if TARGET_OS_IPHONE || __native_client__ || __EMSCRIPTEN__  /* probably not useful on iOS, NACL or Emscripten. */
                                             ^

src/main/android/../../dynapi/SDL_dynapi.h:48:7: warning: 'SDL_BUILDING_WINRT' is not defined, evaluates to 0 [-Wundef]
#elif SDL_BUILDING_WINRT /* probaly not useful on WinRT, given current .dll loading restrictions */
      ^
src/main/android/../../dynapi/SDL_dynapi.h:50:7: warning: '__PSP__' is not defined, evaluates to 0 [-Wundef]
#elif __PSP__
      ^

src/main/android/SDL_android_main.c:20:23: warning: no previous prototype for function 'Java_org_libsdl_app_SDLActivity_nativeInit' [-Wmissing-prototypes]
JNIEXPORT int JNICALL Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject array)
Comment 1 Philipp Wiesemann 2016-07-17 18:48:26 UTC
The warnings for "-Wundef" should have been fixed here: https://hg.libsdl.org/SDL/rev/623c40e8fd65

The header file was changed (instead of "SDL_android_main.c") because this prevents the same problem to show up for other platform's "main.c" files someday.
Comment 2 Sylvain 2016-07-17 19:05:40 UTC
Thanks, the "undef" warnings are now fixed.


Only remains the warning for the prototype declaration of "nativeInit":

/src/main/android/SDL_android_main.c:20:23: 
warning: no previous prototype for function 'Java_org_libsdl_app_SDLActivity_nativeInit' [-Wmissing-prototypes]
JNIEXPORT int JNICALL Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject array)
                      ^
Comment 3 Philipp Wiesemann 2016-07-17 20:01:51 UTC
The warning for "-Wmissing-prototypes" should have been fixed here: https://hg.libsdl.org/SDL/rev/136b3507f669

Thanks!
Comment 4 Sylvain 2016-07-17 20:28:07 UTC
Yes this is fixed, thanks.