The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
TARGET_OS_IPHONE
Owen Alanzo Hogarth
Guest

I can find this in the sdl source code but nothing similar for android. Is there a define for android?
TARGET_OS_IPHONE
DLudwig


Joined: 09 Feb 2012
Posts: 179
__ANDROID__ gets #define'd to 1 on Android, by SDL 2.x, via the public header, SDL_platform.h.

There's a bunch of similar platform-specific #defines in there, too.


To note, TARGET_OS_IPHONE is not SDL specific, but is one of Apple + iOS' own platform declaration macros.  If I remember correctly, SDL uses it under the hood to define __IPHONEOS__ (which gets #define'd for any version of iOS, not just those running on phone hardware).


-- David L.






On Mon, Oct 5, 2015 at 7:09 AM, Owen Alanzo Hogarth wrote:
Quote:
I can find this in the sdl source code but nothing similar for android. Is there a define for android?

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

TARGET_OS_IPHONE
Alex Szpakowski
Guest

Indeed. Check out the SDL_platform.h header to see what SDL defines on various platforms:
https://bitbucket.org/slime73/sdl-experiments/src/1fdb63e14757e2ea0a20b11c73d79fe8bb897919/include/SDL_platform.h?at=AppleTV&fileviewer=file-view-default
Quote:
On Oct 5, 2015, at 4:32 PM, David Ludwig wrote:
__ANDROID__ gets #define'd to 1 on Android, by SDL 2.x, via the public header, SDL_platform.h.
There's a bunch of similar platform-specific #defines in there, too.

To note, TARGET_OS_IPHONE is not SDL specific, but is one of Apple + iOS' own platform declaration macros. If I remember correctly, SDL uses it under the hood to define __IPHONEOS__ (which gets #define'd for any version of iOS, not just those running on phone hardware).

-- David L.



On Mon, Oct 5, 2015 at 7:09 AM, Owen Alanzo Hogarth wrote:
Quote:
I can find this in the sdl source code but nothing similar for android. Is there a define for android?
_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________SDL mailing://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
TARGET_OS_IPHONE
Owen Alanzo Hogarth
Guest

I noticed these, the reason I asked is because after only including SDL.h I could only use #define _TARGET_OS_IPHONE__ but not ANDROID or __ANDROID__

getting lint errors about __ANDROID__  not being defined.


On Tue, Oct 6, 2015 at 3:43 AM, Alex Szpakowski wrote:
Quote:
Indeed. Check out the SDL_platform.h header to see what SDL defines on various platforms:
https://bitbucket.org/slime73/sdl-experiments/src/1fdb63e14757e2ea0a20b11c73d79fe8bb897919/include/SDL_platform.h?at=AppleTV&fileviewer=file-view-default

Quote:
On Oct 5, 2015, at 4:32 PM, David Ludwig wrote:

__ANDROID__ gets #define'd to 1 on Android, by SDL 2.x, via the public header, SDL_platform.h.

There's a bunch of similar platform-specific #defines in there, too.


To note, TARGET_OS_IPHONE is not SDL specific, but is one of Apple + iOS' own platform declaration macros.  If I remember correctly, SDL uses it under the hood to define __IPHONEOS__ (which gets #define'd for any version of iOS, not just those running on phone hardware).


-- David L.






On Mon, Oct 5, 2015 at 7:09 AM, Owen Alanzo Hogarth wrote:
Quote:
I can find this in the sdl source code but nothing similar for android. Is there a define for android?

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

TARGET_OS_IPHONE
DLudwig


Joined: 09 Feb 2012
Posts: 179
My understanding of how SDL_platform.h (which is #include'd indirectly by SDL.h) works, at least on Android, is that it looks for the presence of macros that would typically be #define'd either by the compiler, or by part of the OS' own SDK(s).

Maybe lint is doing something that causes these macro(s) to break?

That's just a guess, though.  I'm not sure what's up with using lint in Android code, alongside SDL 2.x.  Perhaps someone else knows, though.


-- David L.




On Mon, Oct 5, 2015 at 8:18 PM, Owen Alanzo Hogarth wrote:
Quote:
I noticed these, the reason I asked is because after only including SDL.h I could only use #define _TARGET_OS_IPHONE__ but not ANDROID or __ANDROID__

getting lint errors about __ANDROID__  not being defined.


On Tue, Oct 6, 2015 at 3:43 AM, Alex Szpakowski wrote:
Quote:
Indeed. Check out the SDL_platform.h header to see what SDL defines on various platforms:
https://bitbucket.org/slime73/sdl-experiments/src/1fdb63e14757e2ea0a20b11c73d79fe8bb897919/include/SDL_platform.h?at=AppleTV&fileviewer=file-view-default

Quote:
On Oct 5, 2015, at 4:32 PM, David Ludwig wrote:

__ANDROID__ gets #define'd to 1 on Android, by SDL 2.x, via the public header, SDL_platform.h.

There's a bunch of similar platform-specific #defines in there, too.


To note, TARGET_OS_IPHONE is not SDL specific, but is one of Apple + iOS' own platform declaration macros.  If I remember correctly, SDL uses it under the hood to define __IPHONEOS__ (which gets #define'd for any version of iOS, not just those running on phone hardware).


-- David L.






On Mon, Oct 5, 2015 at 7:09 AM, Owen Alanzo Hogarth wrote:
Quote:
I can find this in the sdl source code but nothing similar for android. Is there a define for android?

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

TARGET_OS_IPHONE
Owen Alanzo Hogarth
Guest

I looked in SDL_platforms before mailing the list. I see that __ANDROID__ and ANDROID is defined in there, I am just unsure why it's causing issues in my code.

The lint is throwing up a warning but things compile fine, I really wish this would go away as it's a big eye sore working with vim and it's constantly highlighted.


On Wed, Oct 7, 2015 at 1:04 AM, David Ludwig wrote:
Quote:
My understanding of how SDL_platform.h (which is #include'd indirectly by SDL.h) works, at least on Android, is that it looks for the presence of macros that would typically be #define'd either by the compiler, or by part of the OS' own SDK(s).

Maybe lint is doing something that causes these macro(s) to break?

That's just a guess, though.  I'm not sure what's up with using lint in Android code, alongside SDL 2.x.  Perhaps someone else knows, though.


-- David L.




On Mon, Oct 5, 2015 at 8:18 PM, Owen Alanzo Hogarth wrote:
Quote:
I noticed these, the reason I asked is because after only including SDL.h I could only use #define _TARGET_OS_IPHONE__ but not ANDROID or __ANDROID__

getting lint errors about __ANDROID__  not being defined.


On Tue, Oct 6, 2015 at 3:43 AM, Alex Szpakowski wrote:
Quote:
Indeed. Check out the SDL_platform.h header to see what SDL defines on various platforms:
https://bitbucket.org/slime73/sdl-experiments/src/1fdb63e14757e2ea0a20b11c73d79fe8bb897919/include/SDL_platform.h?at=AppleTV&fileviewer=file-view-default

Quote:
On Oct 5, 2015, at 4:32 PM, David Ludwig wrote:

__ANDROID__ gets #define'd to 1 on Android, by SDL 2.x, via the public header, SDL_platform.h.

There's a bunch of similar platform-specific #defines in there, too.


To note, TARGET_OS_IPHONE is not SDL specific, but is one of Apple + iOS' own platform declaration macros.  If I remember correctly, SDL uses it under the hood to define __IPHONEOS__ (which gets #define'd for any version of iOS, not just those running on phone hardware).


-- David L.






On Mon, Oct 5, 2015 at 7:09 AM, Owen Alanzo Hogarth wrote:
Quote:
I can find this in the sdl source code but nothing similar for android. Is there a define for android?

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

TARGET_OS_IPHONE
Owen Alanzo Hogarth
Guest

I might be able to solve this issue a different way.

I am just trying to find if this instance of SDL is being ran on mobile or desktop platform. Is there a standard way to find out is the app being run on mobile or desktop w/o using those statements?


On Wed, Oct 7, 2015 at 11:10 AM, Owen Alanzo Hogarth wrote:
Quote:
I looked in SDL_platforms before mailing the list. I see that __ANDROID__ and ANDROID is defined in there, I am just unsure why it's causing issues in my code.

The lint is throwing up a warning but things compile fine, I really wish this would go away as it's a big eye sore working with vim and it's constantly highlighted.


On Wed, Oct 7, 2015 at 1:04 AM, David Ludwig wrote:
Quote:
My understanding of how SDL_platform.h (which is #include'd indirectly by SDL.h) works, at least on Android, is that it looks for the presence of macros that would typically be #define'd either by the compiler, or by part of the OS' own SDK(s).

Maybe lint is doing something that causes these macro(s) to break?

That's just a guess, though.  I'm not sure what's up with using lint in Android code, alongside SDL 2.x.  Perhaps someone else knows, though.


-- David L.




On Mon, Oct 5, 2015 at 8:18 PM, Owen Alanzo Hogarth wrote:
Quote:
I noticed these, the reason I asked is because after only including SDL.h I could only use #define _TARGET_OS_IPHONE__ but not ANDROID or __ANDROID__

getting lint errors about __ANDROID__  not being defined.


On Tue, Oct 6, 2015 at 3:43 AM, Alex Szpakowski wrote:
Quote:
Indeed. Check out the SDL_platform.h header to see what SDL defines on various platforms:
https://bitbucket.org/slime73/sdl-experiments/src/1fdb63e14757e2ea0a20b11c73d79fe8bb897919/include/SDL_platform.h?at=AppleTV&fileviewer=file-view-default

Quote:
On Oct 5, 2015, at 4:32 PM, David Ludwig wrote:

__ANDROID__ gets #define'd to 1 on Android, by SDL 2.x, via the public header, SDL_platform.h.

There's a bunch of similar platform-specific #defines in there, too.


To note, TARGET_OS_IPHONE is not SDL specific, but is one of Apple + iOS' own platform declaration macros.  If I remember correctly, SDL uses it under the hood to define __IPHONEOS__ (which gets #define'd for any version of iOS, not just those running on phone hardware).


-- David L.






On Mon, Oct 5, 2015 at 7:09 AM, Owen Alanzo Hogarth wrote:
Quote:
I can find this in the sdl source code but nothing similar for android. Is there a define for android?

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org






Re: TARGET_OS_IPHONE
DLudwig


Joined: 09 Feb 2012
Posts: 179
Owen Alanzo Hogarth wrote:
I might be able to solve this issue a different way.

I am just trying to find if this instance of SDL is being ran on mobile or desktop platform. Is there a standard way to find out is the app being run on mobile or desktop w/o using those statements?


There is also a function, 'const char * SDL_GetPlatform(void)', which will return a string that attempts to identify the current platform. Under the hood, it uses a bunch of #if/#elif/#endif directives on those SDL #defines (like __ANDROID__, __IPHONEOS__, __WIN32__, etc.), to figure out which string to return.

-- David L.