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 777 - Add SDL_PlatformName() function to get name of the platform running on
Summary: Add SDL_PlatformName() function to get name of the platform running on
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: All All
: P2 enhancement
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-06 01:32 UTC by Edgar Simo
Modified: 2009-09-26 03:32 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Edgar Simo 2009-08-06 01:32:18 UTC
I think it would be good to have a function like SDL_PlatformName() to get the name of the platform SDL is currently running on. There is sample code in test/testplatform.c which does this. This would help developers with making prettier debugging information containing what OS the application is running on.

The function is pretty simple and would be added to the SDL_platform.h header.

The currently used implementation in testplatform.c is the following:

/**
 * @brief Gets the name of the platform.
 */
const char *SDL_PlatformName (void)
{
   return
#if __AIX__   
      "AIX"
#elif __BEOS__
      "BeOS"
#elif __BSDI__
      "BSDI"
#elif __DREAMCAST__
      "Dreamcast"
#elif __FREEBSD__
      "FreeBSD"
#elif __HPUX__ 
      "HP-UX"
#elif __IRIX__ 
      "Irix"
#elif __LINUX__
      "Linux"
#elif __MINT__
      "Atari MiNT"
#elif __MACOS__
      "MacOS Classic"
#elif __MACOSX__
      "Mac OS X"
#elif __NETBSD__
      "NetBSD"
#elif __OPENBSD__
      "OpenBSD"
#elif __OS2__ 
      "OS/2"
#elif __OSF__ 
      "OSF/1"
#elif __QNXNTO__
      "QNX Neutrino"
#elif __RISCOS__
      "RISC OS"
#elif __SOLARIS__
      "Solaris"
#elif __WIN32__
#ifdef _WIN32_WCE
      "Windows CE"
#else         
      "Windows"
#endif
#elif __IPHONEOS__
      "iPhone OS"
#else         
      "an unknown operating system! (see SDL_platform.h)"
#endif     
      ;
}
Comment 1 Sam Lantinga 2009-09-26 03:32:33 UTC
Good idea, I added this to subversion.  Thanks!