Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / August 2005



Tip: Looking for answers? Try searching our database.

small compile warning, not sure why

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith Wiley - 16 Aug 2005 18:03 GMT
I took this code verbatim out of the CFPreferences docs:

int dropMethod = 0;
CFStringRef dropMethodKey = CFSTR("dropMethod");
CFNumberRef dropMethodVal = CFPreferencesCopyAppValue(dropMethodKey,
kCFPreferencesCurrentApplication);
if (dropMethodVal)
{
    if (!CFNumberGetValue(dropMethodVal, kCFNumberIntType,
&dropMethod))
        dropMethod = 0;
    CFRelease(dropMethodVal);
}
else dropMethod = 0;

I get a warning on the third line (assignment to dropMethodVal).  The
warning is:

Invalid conversion from 'const void*' to 'const __CFNumber*'

Like I said, this is practically verbatim from the dos.  The application
runs fine.  It saves and retrieves preferences without any trouble after
multiple app launches.   I just don't understand why I'm getting warning
for code from the docs.  Is it actually wrong?  Should I just put a cast
in front of it to get rid of the warning even thought the docs didn't use
a cast?

Thanks.

________________________________________________________________________
Keith Wiley         kwiley@cs.unm.edu         http://www.unm.edu/~keithw

"Yet mark his perfect self-contentment, and hence learn his lesson,
that to be self-contented is to be vile and ignorant, and that to
aspire is better than to be blindly and impotently happy."
                                           --  Edwin A. Abbott, Flatland
________________________________________________________________________
Eric Albert - 16 Aug 2005 19:09 GMT
> I took this code verbatim out of the CFPreferences docs:
>
[quoted text clipped - 22 lines]
> in front of it to get rid of the warning even thought the docs didn't use
> a cast?

Yep...CFPreferencesCopyAppValue returns a CFPropertyListRef, which is a
CFTypeRef, which is a const void *.  In C++ (I think), you can't
implicitly convert from a void * to another pointer type.  You have to
cast the return value to the right type.

So yeah, add a cast to CFNumberRef and file a bug against the
documentation.

-Eric

Signature

Eric Albert         ejalbert@cs.stanford.edu
http://outofcheese.org/

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.