Re: iPhone Platform Compiler Symbol?
Re: iPhone Platform Compiler Symbol?
- Subject: Re: iPhone Platform Compiler Symbol?
- From: Clark Cox <email@hidden>
- Date: Thu, 14 May 2009 21:18:27 -0700
On Thu, May 14, 2009 at 9:13 PM, Gwynne Raskind <email@hidden> wrote:
> On May 14, 2009, at 11:45 PM, Clark Cox wrote:
>>>>
>>>> # gcc -dM -E -x c /dev/null > gccdefs.txt
>>>>
>>>> and
>>>>
>>>> # cpp -dM < /dev/null > cppdefs.txt
>>>>
>>>> Show no difference in the output files.
>>>> I think cpp is currently a call through to gcc so theoretically they
>>>> should always produce the same set of defines given equivalent options.
>>>>
>>>> True or false?
>>>
>>> True, though the whole story is slightly more complicated. A little
>>> fiddling
>>> about with the -v flag actually shows the following:
>>>
>>> 1. cpp is a wrapper for gcc-4.0 -E
>>> 2. gcc-4.0 -E in turn calls through to cc1 -E -traditional-cpp
>>> 3. cpp-4.2 and gcc-4.2 call through to cc1 -E
>>>
>>> As a side note, one of the correct answers to the OP's question is:
>>>
>>> #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1
>>
>> "#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1"
>> and
>> "#if TARGET_OS_IPHONE == 1"
>> are 100% synonymous. On top of that, I would recommend just using:
>> "#if TARGET_OS_IPHONE"
>
> You've never written PHP, have you? :)
>
> But anyway, try setting your base SDK to MacOSX10.5 and doing "#if
> TARGET_OS_IPHONE". You'll get a compiler warning for an undefined macro
> (unless you have that warning shut off). A harmless warning, but my version
> avoids it in all cases without any penalty.
If you must use your version, at least do:
"#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE"
This protects against any future headers that may define
TARGET_OS_IPHONE to something other than 1.
--
Clark S. Cox III
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden