Get Operating System at Run Time

Started by
11 comments, last by Xai 17 years, 6 months ago
Quote:
That doesn't make any sense, given that try-except is a Windows specific construct.


I figured he meant try/catch. try/except is niether C++ (which using try/catch) nor Windows SEH-specific (which uses __try/__except). So I guess it could either way, but either way, it won't work.
Advertisement
Quote:Original post by Anonymous Poster
Quote:I know how to use defines to work out what platform it was built on and I can still use that method if need be.

http://predef.sourceforge.net/
i find it funny that within 30 mins you have forgot the defines!


He said he knows how to use defines to work this problem out. He didn't say he knew what the specific OS defines were...

Anyway,

__WIN32__ for windows
__APPLE_CC__ for mac
__LINUX__ for linux

those are the ones i know...


[size=2]aliak.net
the try/catch block can't work either ... because it is platform specific code. You can't CALL a function that your program doesn't know about, and when it is compiled for each platform it will only be linked to the libraries for that platform. So all fundamentally incompatible distinctions are made at compile time (using the defines). Once you know the top-level platform at compile time, you can invoke the platform specific run-time functions from their.

This topic is closed to new replies.

Advertisement