OS, version, CPU

Hi everyone,

I’ve noticed that SDL doesn’t really have a means to determine the OS
and version. Largely that makes sense because SDL doesn’t care about
that. It wants to know about what backends are supported, and which
ones you’re using right now.

I’m not 100% convinced on this, but if SDL should actually know these
things, I imagine it should be able to tell you:

  • OS version (string, system dependent)
  • CPU string, possibly also system dependent, but “standardized”?
  • Platform enum: UNKNOWN, WINDOWS, DARWIN, LINUX, BSD, etc?

Is this something SDL should know at runtime, and should apps/games
be able to query it (or anything like it) for some reason? I think
the first two would be quite useful for debug logs and the like. I
can’t imagine how many times someone has come to #SDL with an issue
and the first questions you have to ask them are inevitably what OS
are they running, what SDL version, how did they install it, etc?

If you’ve gotta prompt developers to tell you this stuff, good luck
with end users? :wink:

The platform enum I admit is of limited use for most applications.
Useful for me as context for SDL’s Joystick GUIDs, but not too many
uses otherwise.

Joseph

Check out SDL_platform.h for #1 and #3. SDL_cpuinfo.h covers #2 somewhat.On Oct 27, 2013, at 2:01 AM, T. Joseph Carter wrote:

  • OS version (string, system dependent)
  • CPU string, possibly also system dependent, but “standardized”?
  • Platform enum: UNKNOWN, WINDOWS, DARWIN, LINUX, BSD, etc?

http://wiki.libsdl.org/SDL_GetPlatform returns the basic platform
(windows, osx, linux, etc) as a string. You can also ifdef some of
these platforms at compile time as your binary will not target OSX and
windows at the same time for an example.On Sun, Oct 27, 2013 at 1:01 AM, T. Joseph Carter wrote:

Hi everyone,

I’ve noticed that SDL doesn’t really have a means to determine the OS and
version. Largely that makes sense because SDL doesn’t care about that. It
wants to know about what backends are supported, and which ones you’re using
right now.

I’m not 100% convinced on this, but if SDL should actually know these
things, I imagine it should be able to tell you:

  • OS version (string, system dependent)
  • CPU string, possibly also system dependent, but “standardized”?
  • Platform enum: UNKNOWN, WINDOWS, DARWIN, LINUX, BSD, etc?

Is this something SDL should know at runtime, and should apps/games be able
to query it (or anything like it) for some reason? I think the first two
would be quite useful for debug logs and the like. I can’t imagine how many
times someone has come to #SDL with an issue and the first questions you
have to ask them are inevitably what OS are they running, what SDL version,
how did they install it, etc?

If you’ve gotta prompt developers to tell you this stuff, good luck with end
users? :wink:

The platform enum I admit is of limited use for most applications. Useful
for me as context for SDL’s Joystick GUIDs, but not too many uses otherwise.

Joseph


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Well, SDL_platform.h covers what I intended to do with #3, but not
really what I intended for an enum. But I did say that I didn’t see
many uses for the enum beyond what I was doing, so I withdraw that
from consideration. The notion of using #ifdef WIN32 on a
decidedly 64 bit or not even Intel-based version of Windows is
amusing, but whatever? :slight_smile:

SDL_GetPlatform doesn’t report an OS version at all. Let’s take the
output of “Windows” again. How useful is that? “Windows”. That
could mean:

  • Windows 95 on an old 486
  • Windows Mobile 5 (Windows CE!) on an old cell phone
  • Windows RT on an ARM-based tablet
  • Windows 7 on an x86_64

Very different systems. Very different kernels. Very different
architectures and feature sets. And while I don’t know if SDL would
compile on a Windows CE system, it should be a minor thing to get it
to do so if someone is crazy enough to try it! It does “run” under
Windows 9x just fine. Heck, I bet it’ll compile out of the tarball
on Windows NT 4.0.

Version tends to matter a lot more on Windows than it does on Linux,
but it also tends to matter on iOS where iOS 5 is still realistic for
SDL to encounter, Android which is all over the map in terms of
versions and features, and the Mac where 10.4 is still seen now and
again.

JosephOn Sun, Oct 27, 2013 at 02:08:41AM -0300, Alex Szpakowski wrote:

Check out SDL_platform.h for #1 and #3. SDL_cpuinfo.h covers #2 somewhat.

On Oct 27, 2013, at 2:01 AM, T. Joseph Carter <@T_Joseph_Carter> wrote:

  • OS version (string, system dependent)
  • CPU string, possibly also system dependent, but “standardized”?
  • Platform enum: UNKNOWN, WINDOWS, DARWIN, LINUX, BSD, etc?

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Do if an ifdef win32 with GetVersionExOn Sun, Oct 27, 2013 at 1:56 AM, T. Joseph Carter wrote:

Well, SDL_platform.h covers what I intended to do with #3, but not really
what I intended for an enum. But I did say that I didn’t see many uses for
the enum beyond what I was doing, so I withdraw that from consideration.
The notion of using #ifdef WIN32 on a decidedly 64 bit or not even
Intel-based version of Windows is amusing, but whatever? :slight_smile:

SDL_GetPlatform doesn’t report an OS version at all. Let’s take the output
of “Windows” again. How useful is that? “Windows”. That could mean:

  • Windows 95 on an old 486
  • Windows Mobile 5 (Windows CE!) on an old cell phone
  • Windows RT on an ARM-based tablet
  • Windows 7 on an x86_64

Very different systems. Very different kernels. Very different
architectures and feature sets. And while I don’t know if SDL would compile
on a Windows CE system, it should be a minor thing to get it to do so if
someone is crazy enough to try it! It does “run” under Windows 9x just
fine. Heck, I bet it’ll compile out of the tarball on Windows NT 4.0.

Version tends to matter a lot more on Windows than it does on Linux, but it
also tends to matter on iOS where iOS 5 is still realistic for SDL to
encounter, Android which is all over the map in terms of versions and
features, and the Mac where 10.4 is still seen now and again.

Joseph

On Sun, Oct 27, 2013 at 02:08:41AM -0300, Alex Szpakowski wrote:

Check out SDL_platform.h for #1 and #3. SDL_cpuinfo.h covers #2 somewhat.

On Oct 27, 2013, at 2:01 AM, T. Joseph Carter wrote:

  • OS version (string, system dependent)
  • CPU string, possibly also system dependent, but “standardized”?
  • Platform enum: UNKNOWN, WINDOWS, DARWIN, LINUX, BSD, etc?

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Shall I also have ifdefs for Darwin, for Linux, for BSD?? I can’t
imagine the number of times I’ve seen “portable” code assume that
there’s WIN32 or linux and if neither one?

#error “There are only 2 OSes in the universe, foolish human!”

I’d really rather not encourage people to write more of it.

Obviously as of 2.0.1 that’s the only way you’re going to get an OS
version. But asking the OS how much memory is installed was just
added to SDL because someone thought it oughtta be supported. I tend
to need to know what a user is running a whole lot more often than
how much RAM they’ve got, personally.

JosephOn Sun, Oct 27, 2013 at 02:45:55AM -0400, Andre D wrote:

Do if an ifdef win32 with GetVersionEx

On Sun, Oct 27, 2013 at 1:56 AM, T. Joseph Carter <@T_Joseph_Carter> wrote:

Well, SDL_platform.h covers what I intended to do with #3, but not really
what I intended for an enum. But I did say that I didn’t see many uses for
the enum beyond what I was doing, so I withdraw that from consideration.
The notion of using #ifdef WIN32 on a decidedly 64 bit or not even
Intel-based version of Windows is amusing, but whatever? :slight_smile:

SDL_GetPlatform doesn’t report an OS version at all. Let’s take the output
of “Windows” again. How useful is that? “Windows”. That could mean:

  • Windows 95 on an old 486
  • Windows Mobile 5 (Windows CE!) on an old cell phone
  • Windows RT on an ARM-based tablet
  • Windows 7 on an x86_64

Very different systems. Very different kernels. Very different
architectures and feature sets. And while I don’t know if SDL would compile
on a Windows CE system, it should be a minor thing to get it to do so if
someone is crazy enough to try it! It does “run” under Windows 9x just
fine. Heck, I bet it’ll compile out of the tarball on Windows NT 4.0.

Version tends to matter a lot more on Windows than it does on Linux, but it
also tends to matter on iOS where iOS 5 is still realistic for SDL to
encounter, Android which is all over the map in terms of versions and
features, and the Mac where 10.4 is still seen now and again.

Joseph

On Sun, Oct 27, 2013 at 02:08:41AM -0300, Alex Szpakowski wrote:

Check out SDL_platform.h for #1 and #3. SDL_cpuinfo.h covers #2 somewhat.

On Oct 27, 2013, at 2:01 AM, T. Joseph Carter <@T_Joseph_Carter> wrote:

  • OS version (string, system dependent)
  • CPU string, possibly also system dependent, but “standardized”?
  • Platform enum: UNKNOWN, WINDOWS, DARWIN, LINUX, BSD, etc?

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I only mentioned windows because I assumed you had no reason to detect
a BSD or Linux kernel (or what, are you going to detect every distro?)
for an SDL application.On Sun, Oct 27, 2013 at 3:43 AM, T. Joseph Carter wrote:

Shall I also have ifdefs for Darwin, for Linux, for BSD?? I can’t imagine
the number of times I’ve seen “portable” code assume that there’s WIN32
or linux and if neither one?

#error “There are only 2 OSes in the universe, foolish human!”

I’d really rather not encourage people to write more of it.

Obviously as of 2.0.1 that’s the only way you’re going to get an OS version.
But asking the OS how much memory is installed was just added to SDL because
someone thought it oughtta be supported. I tend to need to know what a user
is running a whole lot more often than how much RAM they’ve got, personally.

Joseph

On Sun, Oct 27, 2013 at 02:45:55AM -0400, Andre D wrote:

Do if an ifdef win32 with GetVersionEx

On Sun, Oct 27, 2013 at 1:56 AM, T. Joseph Carter wrote:

Well, SDL_platform.h covers what I intended to do with #3, but not really
what I intended for an enum. But I did say that I didn’t see many uses
for
the enum beyond what I was doing, so I withdraw that from consideration.
The notion of using #ifdef WIN32 on a decidedly 64 bit or not even
Intel-based version of Windows is amusing, but whatever? :slight_smile:

SDL_GetPlatform doesn’t report an OS version at all. Let’s take the
output
of “Windows” again. How useful is that? “Windows”. That could mean:

  • Windows 95 on an old 486
  • Windows Mobile 5 (Windows CE!) on an old cell phone
  • Windows RT on an ARM-based tablet
  • Windows 7 on an x86_64

Very different systems. Very different kernels. Very different
architectures and feature sets. And while I don’t know if SDL would
compile
on a Windows CE system, it should be a minor thing to get it to do so if
someone is crazy enough to try it! It does “run” under Windows 9x just
fine. Heck, I bet it’ll compile out of the tarball on Windows NT 4.0.

Version tends to matter a lot more on Windows than it does on Linux, but
it
also tends to matter on iOS where iOS 5 is still realistic for SDL to
encounter, Android which is all over the map in terms of versions and
features, and the Mac where 10.4 is still seen now and again.

Joseph

On Sun, Oct 27, 2013 at 02:08:41AM -0300, Alex Szpakowski wrote:

Check out SDL_platform.h for #1 and #3. SDL_cpuinfo.h covers #2
somewhat.

On Oct 27, 2013, at 2:01 AM, T. Joseph Carter wrote:

  • OS version (string, system dependent)
  • CPU string, possibly also system dependent, but “standardized”?
  • Platform enum: UNKNOWN, WINDOWS, DARWIN, LINUX, BSD, etc?

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Sorry, kernel version.On Sun, Oct 27, 2013 at 3:46 AM, Andre D <@Andre_D> wrote:

I only mentioned windows because I assumed you had no reason to detect
a BSD or Linux kernel (or what, are you going to detect every distro?)
for an SDL application.

On Sun, Oct 27, 2013 at 3:43 AM, T. Joseph Carter wrote:

Shall I also have ifdefs for Darwin, for Linux, for BSD?? I can’t imagine
the number of times I’ve seen “portable” code assume that there’s WIN32
or linux and if neither one?

#error “There are only 2 OSes in the universe, foolish human!”

I’d really rather not encourage people to write more of it.

Obviously as of 2.0.1 that’s the only way you’re going to get an OS version.
But asking the OS how much memory is installed was just added to SDL because
someone thought it oughtta be supported. I tend to need to know what a user
is running a whole lot more often than how much RAM they’ve got, personally.

Joseph

On Sun, Oct 27, 2013 at 02:45:55AM -0400, Andre D wrote:

Do if an ifdef win32 with GetVersionEx

On Sun, Oct 27, 2013 at 1:56 AM, T. Joseph Carter wrote:

Well, SDL_platform.h covers what I intended to do with #3, but not really
what I intended for an enum. But I did say that I didn’t see many uses
for
the enum beyond what I was doing, so I withdraw that from consideration.
The notion of using #ifdef WIN32 on a decidedly 64 bit or not even
Intel-based version of Windows is amusing, but whatever? :slight_smile:

SDL_GetPlatform doesn’t report an OS version at all. Let’s take the
output
of “Windows” again. How useful is that? “Windows”. That could mean:

  • Windows 95 on an old 486
  • Windows Mobile 5 (Windows CE!) on an old cell phone
  • Windows RT on an ARM-based tablet
  • Windows 7 on an x86_64

Very different systems. Very different kernels. Very different
architectures and feature sets. And while I don’t know if SDL would
compile
on a Windows CE system, it should be a minor thing to get it to do so if
someone is crazy enough to try it! It does “run” under Windows 9x just
fine. Heck, I bet it’ll compile out of the tarball on Windows NT 4.0.

Version tends to matter a lot more on Windows than it does on Linux, but
it
also tends to matter on iOS where iOS 5 is still realistic for SDL to
encounter, Android which is all over the map in terms of versions and
features, and the Mac where 10.4 is still seen now and again.

Joseph

On Sun, Oct 27, 2013 at 02:08:41AM -0300, Alex Szpakowski wrote:

Check out SDL_platform.h for #1 and #3. SDL_cpuinfo.h covers #2
somewhat.

On Oct 27, 2013, at 2:01 AM, T. Joseph Carter wrote:

  • OS version (string, system dependent)
  • CPU string, possibly also system dependent, but “standardized”?
  • Platform enum: UNKNOWN, WINDOWS, DARWIN, LINUX, BSD, etc?

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

The fact of the matter is, there is no portable way to do so. Thus,
why are you scoffing at ifdeffing various platform implementations.On Sun, Oct 27, 2013 at 3:47 AM, Andre D <@Andre_D> wrote:

Sorry, kernel version.

On Sun, Oct 27, 2013 at 3:46 AM, Andre D <@Andre_D> wrote:

I only mentioned windows because I assumed you had no reason to detect
a BSD or Linux kernel (or what, are you going to detect every distro?)
for an SDL application.

On Sun, Oct 27, 2013 at 3:43 AM, T. Joseph Carter wrote:

Shall I also have ifdefs for Darwin, for Linux, for BSD?? I can’t imagine
the number of times I’ve seen “portable” code assume that there’s WIN32
or linux and if neither one?

#error “There are only 2 OSes in the universe, foolish human!”

I’d really rather not encourage people to write more of it.

Obviously as of 2.0.1 that’s the only way you’re going to get an OS version.
But asking the OS how much memory is installed was just added to SDL because
someone thought it oughtta be supported. I tend to need to know what a user
is running a whole lot more often than how much RAM they’ve got, personally.

Joseph

On Sun, Oct 27, 2013 at 02:45:55AM -0400, Andre D wrote:

Do if an ifdef win32 with GetVersionEx

On Sun, Oct 27, 2013 at 1:56 AM, T. Joseph Carter wrote:

Well, SDL_platform.h covers what I intended to do with #3, but not really
what I intended for an enum. But I did say that I didn’t see many uses
for
the enum beyond what I was doing, so I withdraw that from consideration.
The notion of using #ifdef WIN32 on a decidedly 64 bit or not even
Intel-based version of Windows is amusing, but whatever? :slight_smile:

SDL_GetPlatform doesn’t report an OS version at all. Let’s take the
output
of “Windows” again. How useful is that? “Windows”. That could mean:

  • Windows 95 on an old 486
  • Windows Mobile 5 (Windows CE!) on an old cell phone
  • Windows RT on an ARM-based tablet
  • Windows 7 on an x86_64

Very different systems. Very different kernels. Very different
architectures and feature sets. And while I don’t know if SDL would
compile
on a Windows CE system, it should be a minor thing to get it to do so if
someone is crazy enough to try it! It does “run” under Windows 9x just
fine. Heck, I bet it’ll compile out of the tarball on Windows NT 4.0.

Version tends to matter a lot more on Windows than it does on Linux, but
it
also tends to matter on iOS where iOS 5 is still realistic for SDL to
encounter, Android which is all over the map in terms of versions and
features, and the Mac where 10.4 is still seen now and again.

Joseph

On Sun, Oct 27, 2013 at 02:08:41AM -0300, Alex Szpakowski wrote:

Check out SDL_platform.h for #1 and #3. SDL_cpuinfo.h covers #2
somewhat.

On Oct 27, 2013, at 2:01 AM, T. Joseph Carter wrote:

  • OS version (string, system dependent)
  • CPU string, possibly also system dependent, but “standardized”?
  • Platform enum: UNKNOWN, WINDOWS, DARWIN, LINUX, BSD, etc?

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

A lot can be determined by the equivalent of uname -rs on systems
that have it.

Linux 3.11.0-12-generic (x86_64)

That tells me:

  • You’re using a packaged kernel, so I shouldn’t need to ask you
    about whether you compiled in a driver for something commonplace.
  • You can’t load a 32 bit plugin

It allows me to infer a lot of other things as well, because Debian,
Ubuntu, Red Hat, etc. tend to use different things in their extra
version. Probably more than a few people on this list could ID that
kernel, the distribution it came from, and what release, with a very
high degree of accuracy.

Darwin 13.0.0 (x86_64)

That tells me:

  • You’re a Mac user whose OS is less than a week from release :wink:
  • You’re running this on the desktop, not an iPad or something

Windows 5.1.2600 (x86)

This tells me:

  • You need an OS upgrade (you’re running XP SP3)
  • You have the common 32 bit version. That’s good, because if you
    had the 64 bit version there’d be a whole set of possible issues to
    address, and we don’t have to deal with any of them.

Haiku 1 (x86)

That tells me very little. There might be more useful version
information on BeOS/Haiku available to a developer, but uname -rs on
the system just spits out “Haiku 1”. I did just about hit the floor
when I did a gcc --version on it: 2.95.3! O_O

That’s what I’ve got on hand at the moment.

JosephOn Sun, Oct 27, 2013 at 03:46:04AM -0400, Andre D wrote:

I only mentioned windows because I assumed you had no reason to detect
a BSD or Linux kernel (or what, are you going to detect every distro?)
for an SDL application.

On Sun, Oct 27, 2013 at 3:43 AM, T. Joseph Carter <@T_Joseph_Carter> wrote:

Shall I also have ifdefs for Darwin, for Linux, for BSD?? I can’t imagine
the number of times I’ve seen “portable” code assume that there’s WIN32
or linux and if neither one?

#error “There are only 2 OSes in the universe, foolish human!”

I’d really rather not encourage people to write more of it.

Obviously as of 2.0.1 that’s the only way you’re going to get an OS version.
But asking the OS how much memory is installed was just added to SDL because
someone thought it oughtta be supported. I tend to need to know what a user
is running a whole lot more often than how much RAM they’ve got, personally.

Joseph

On Sun, Oct 27, 2013 at 02:45:55AM -0400, Andre D wrote:

Do if an ifdef win32 with GetVersionEx

On Sun, Oct 27, 2013 at 1:56 AM, T. Joseph Carter <@T_Joseph_Carter> wrote:

Well, SDL_platform.h covers what I intended to do with #3, but not really
what I intended for an enum. But I did say that I didn’t see many uses
for
the enum beyond what I was doing, so I withdraw that from consideration.
The notion of using #ifdef WIN32 on a decidedly 64 bit or not even
Intel-based version of Windows is amusing, but whatever? :slight_smile:

SDL_GetPlatform doesn’t report an OS version at all. Let’s take the
output
of “Windows” again. How useful is that? “Windows”. That could mean:

  • Windows 95 on an old 486
  • Windows Mobile 5 (Windows CE!) on an old cell phone
  • Windows RT on an ARM-based tablet
  • Windows 7 on an x86_64

Very different systems. Very different kernels. Very different
architectures and feature sets. And while I don’t know if SDL would
compile
on a Windows CE system, it should be a minor thing to get it to do so if
someone is crazy enough to try it! It does “run” under Windows 9x just
fine. Heck, I bet it’ll compile out of the tarball on Windows NT 4.0.

Version tends to matter a lot more on Windows than it does on Linux, but
it
also tends to matter on iOS where iOS 5 is still realistic for SDL to
encounter, Android which is all over the map in terms of versions and
features, and the Mac where 10.4 is still seen now and again.

Joseph

On Sun, Oct 27, 2013 at 02:08:41AM -0300, Alex Szpakowski wrote:

Check out SDL_platform.h for #1 and #3. SDL_cpuinfo.h covers #2
somewhat.

On Oct 27, 2013, at 2:01 AM, T. Joseph Carter <@T_Joseph_Carter> wrote:

  • OS version (string, system dependent)
  • CPU string, possibly also system dependent, but “standardized”?
  • Platform enum: UNKNOWN, WINDOWS, DARWIN, LINUX, BSD, etc?

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Well, if I’m just going to #ifdef all of my code for different
platforms, what’s SDL for exactly?

JosephOn Sun, Oct 27, 2013 at 03:56:15AM -0400, Andre D wrote:

The fact of the matter is, there is no portable way to do so. Thus,
why are you scoffing at ifdeffing various platform implementations.

On Sun, Oct 27, 2013 at 3:47 AM, Andre D wrote:

Sorry, kernel version.

On Sun, Oct 27, 2013 at 3:46 AM, Andre D wrote:

I only mentioned windows because I assumed you had no reason to detect
a BSD or Linux kernel (or what, are you going to detect every distro?)
for an SDL application.

" to provide low level access to audio, keyboard, mouse, joystick, and
graphics hardware via OpenGL and Direct3D."On Sun, Oct 27, 2013 at 4:56 AM, T. Joseph Carter wrote:

Well, if I’m just going to #ifdef all of my code for different platforms,
what’s SDL for exactly?

Joseph

On Sun, Oct 27, 2013 at 03:56:15AM -0400, Andre D wrote:

The fact of the matter is, there is no portable way to do so. Thus,
why are you scoffing at ifdeffing various platform implementations.

On Sun, Oct 27, 2013 at 3:47 AM, Andre D <@Andre_D> wrote:

Sorry, kernel version.

On Sun, Oct 27, 2013 at 3:46 AM, Andre D <@Andre_D> wrote:

I only mentioned windows because I assumed you had no reason to detect
a BSD or Linux kernel (or what, are you going to detect every distro?)
for an SDL application.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Den 27. okt. 2013 09:55, skrev T. Joseph Carter:

It allows me to infer a lot of other things as well, because Debian,
Ubuntu, Red Hat, etc. tend to use different things in their extra
version. Probably more than a few people on this list could ID that
kernel, the distribution it came from, and what release, with a very
high degree of accuracy.

You don’t have to infer these things on modern Linux distros. Parse
/etc/os-release =). It’s not on absolutely everything, but it’s pretty
standard.

-g

2013/10/27, T. Joseph Carter :

Shall I also have ifdefs for Darwin, for Linux, for BSD?? I can’t
imagine the number of times I’ve seen “portable” code assume that
there’s WIN32 or linux and if neither one?

#error “There are only 2 OSes in the universe, foolish human!”

I’d really rather not encourage people to write more of it.

Sadly, I was kind of forced to write platform-specific code when I
needed to add file support to the level editor in my game, since I
needed access outside the PhysicsFS sandbox (to read user files).
While I did manage to trick PhysicsFS into giving me access to the
full filesystem when needed so I could reduce platform-specific code
to a minimum (in its own “sub-sandbox”, for the record), I still need
to cope with the way paths are handled in each OS, so
platform-specific code was needed for that.

Also another place where I use platform-specific code is when I need
to work around SDL bugs and can’t afford to wait for a fix :stuck_out_tongue: But
ideally that kind of code should be gone whenever SDL updates with a
fix.

2013/10/27, T. Joseph Carter :

Obviously as of 2.0.1 that’s the only way you’re going to get an OS
version. But asking the OS how much memory is installed was just
added to SDL because someone thought it oughtta be supported. I tend
to need to know what a user is running a whole lot more often than
how much RAM they’ve got, personally.

Actually, I imagine this could be useful if you want to cache stuff
and want to figure out what would be a good value for this system
(though in practice it tends to result in all programs doing that and
starving RAM like crazy… but whatever, for some stuff like games
that hog most resources for starters it may make sense).

/etc/os-release tells me I’m running Ubuntu, which is not entirely
accurate. (I’m running Linux Mint, which is Ubuntu-compatible and uses
Ubuntu packages, but which also adds its own packages on top of those
provided by Ubuntu.)On 27.10.2013 10:16, Gerry JJ wrote:

You don’t have to infer these things on modern Linux distros. Parse
/etc/os-release =). It’s not on absolutely everything, but it’s pretty
standard.


Rainer Deyke (rainerd at eldwood.com)

Den 27. okt. 2013 11:43, skrev Rainer Deyke:

/etc/os-release tells me I’m running Ubuntu, which is not entirely
accurate. (I’m running Linux Mint, which is Ubuntu-compatible and uses
Ubuntu packages, but which also adds its own packages on top of those
provided by Ubuntu.)

Oh right, I forgot about that =/. Does Mint have some other file in
there with more correct info? lsb-release or something? I know there’s
some way to detect it (wish they’d fix their os-release though)

-g

$ lsb_release -i
Distributor ID: LinuxMintOn 27.10.2013 12:18, Gerry JJ wrote:

Den 27. okt. 2013 11:43, skrev Rainer Deyke:

/etc/os-release tells me I’m running Ubuntu, which is not entirely
accurate. (I’m running Linux Mint, which is Ubuntu-compatible and uses
Ubuntu packages, but which also adds its own packages on top of those
provided by Ubuntu.)

Oh right, I forgot about that =/. Does Mint have some other file in
there with more correct info? lsb-release or something? I know there’s
some way to detect it (wish they’d fix their os-release though)


Rainer Deyke (rainerd at eldwood.com)

Den 27. okt. 2013 13:46, skrev Rainer Deyke:

$ lsb_release -i
Distributor ID: LinuxMint

That’s the lsb_release program, though. It’s a bit silly having to
launch a new process and capture output just to detect the OS version.

There is (or should be) a file called /etc/lsb-release, similar to
os-release, that may contain that information, but iirc it’s not as well
defined, and info can be spread out over several files, etc. Meant to be
used by the lsb_release program, obviously… nice for shell scripts, not
so much everything else…

-g

The point is that you don’t #ifdef all your code for different
platforms. If you do need platform specific code though, why do you
think SDL should be involved? SDL is a layer theat hides platform
differences. Having it occupy the role of platform delegation seems
counter-intuitive.On Sun, 27 Oct 2013 01:56:37 -0700 T. wrote:

Well, if I’m just going to #ifdef all of my code for different
platforms, what’s SDL for exactly?

$ cat /etc/lsb-release
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=15
DISTRIB_CODENAME=olivia
DISTRIB_DESCRIPTION="Linux Mint 15 Olivia"On 27.10.2013 14:23, Gerry JJ wrote:

There is (or should be) a file called /etc/lsb-release, similar to
os-release, that may contain that information, but iirc it’s not as well
defined, and info can be spread out over several files, etc. Meant to be
used by the lsb_release program, obviously… nice for shell scripts, not
so much everything else…


Rainer Deyke (rainerd at eldwood.com)