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 8/31/03 5:34 PM, Ilya Maykov didst favor us with:

> 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?

The OS doesn't use macros, your compiler does. ConditionalMacros.h has
several of these for various releases of the Mac OS, such as
TARGET_API_MAC_OSX, but nothing for Windows. You'd want to use whatever
Windows provides for that one, I assume.

> For example, to have system-specific code I would do something like this:
>
> #if defined MAC_OS_X
> // OS X specific code
> #elif defined WINDOWS
> //windows specific code
> #elif defined SOME_OTHER_OS
> //some other code
> ...
I've never done dual-platform development myself, and I don't know exactly
what you have planned, but consider placing OS-specific code into separate,
OS-specific source files. I've worked on code with these kinds of macros and
not only is it a pain to read, it's harder to maintain, especially if you
want to have different people working on the Mac and Windows and whatever
versions at the same time.

Larry
_______________________________________________
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.