Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: preprocessor directive to determine OS?



On Sunday, August 31, 2003, at 04:34 PM, Ilya Maykov wrote:

> Hi all,
>
> I have a fairly simple question. I'm writing a C/C++ application and
> want to make it cross-platform, so it will include different modules
> for different operating systems. The first target system is OS X 10.2
> or higher, with an eventual port to Win32.


> Can someone tell me, what are the macros used by OS X to indicate the
> OS name and version? For example, to have system-specific code I would
> do something like this:

You can't tell the OS Version from a #define macro used at compile time
to determine a value at run-time. You could compile on 10.2 and in five
years be running on 11.5.


> #if defined MAC_OS_X
> // OS X specific code
> #elif defined WINDOWS
> //windows specific code
> #elif defined SOME_OTHER_OS
> //some other code

Take a look at "ConditionalMacros.h" (CarbonCore framework inside
CoreServices)

In particular things like...

TARGET_OS_MAC
TARGET_OS_WIN32

And so on.
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.

References: 
 >preprocessor directive to determine OS? (From: Ilya Maykov <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.