Allow C++ code to include SDL_android.h
authorSam Lantinga <slouken@libsdl.org>
Sun, 04 Aug 2013 09:23:55 -0700
changeset 7570 716a36edc73c
parent 7569 9fd3f4b23223
child 7571 824c6bacc5b3
Allow C++ code to include SDL_android.h Alexey Petruchik Although SDL_android.h is not intended to be included by client code sometimes it needed. For example you need JNIEnv pointer to make JNI calls to modified SDLActivity.java (video playback, facebook integration, in-apps). It seems a bit weird to write: extern "C" { #include "SDL_android.h" } in my AndroidJNI.cpp file.
src/core/android/SDL_android.h
--- a/src/core/android/SDL_android.h	Sat Aug 03 23:40:28 2013 +0200
+++ b/src/core/android/SDL_android.h	Sun Aug 04 09:23:55 2013 -0700
@@ -20,6 +20,13 @@
 */
 #include "SDL_config.h"
 
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
 #include "SDL_rect.h"
 
 /* Interface from the SDL library into the Android Java activity */
@@ -61,4 +68,11 @@
 /* Generic messages */
 int Android_JNI_SendMessage(int command, int param);
 
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
 /* vi: set ts=4 sw=4 expandtab: */