Re: Supporting Multiple SDK's Without Warnings
Re: Supporting Multiple SDK's Without Warnings
- Subject: Re: Supporting Multiple SDK's Without Warnings
- From: Steve Christensen <email@hidden>
- Date: Sat, 1 Jul 2006 14:28:15 -0700
On Jul 1, 2006, at 8:43 AM, Nick Nallick wrote:
I have some code that builds for older OS versions using
CodeWarrior and also for 10.3.9 and later using Xcode and GCC 4.
It contains a number of patterns similar to the one below. The
idea is to when possible, avoid a runtime check for a function that
must be present.
Rect picFrame;
if (REQUIRE_PANTHER || QDGetPictureBounds)
QDGetPictureBounds(picHdl, &picFrame);
else
picFrame = (**picHdl).picFrame;
I'm presently trying to clean up extraneous warnings in this code
and the above gives me the following warning.
warning: the address of 'Rect* QDGetPictureBounds(Picture**,
Rect*)', will always evaluate as 'true'
Given that for Xcode REQUIRE_PANTHER will also always evaluate as
true this seems rather pointless, not to mention the fact that it's
kind of the point of the whole thing.
Well, the compiler's probably just evaluating all of the pieces of
the "if" statement and alerting you to things you might want to know
about.
I really just want the compiler to shut up and optimize out
everything but the function call. Can anybody suggest another way
to do this without the warning?
Assuming that REQUIRE_PANTHER is #define'd someplace, how about the
following instead?
Rect picFrame;
#if !REQUIRE_PANTHER
if (QDGetPictureBounds == NULL)
picFrame = (*picHdl)->picFrame;
else
#endif
QDGetPictureBounds(picHdl, &picFrame);
The first part gets compiled out for 10.3 and later builds, otherwise
it does a runtime check and uses the appropriate code.
steve
_______________________________________________
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