Re: Change build flags; Ignore warnings; Alter C code?
Re: Change build flags; Ignore warnings; Alter C code?
- Subject: Re: Change build flags; Ignore warnings; Alter C code?
- From: Andrew Thompson <email@hidden>
- Date: Fri, 17 Feb 2006 00:03:24 -0800
CFDataGetBytePtr() returns a const, so you should declare info to be
const UInt8 *info;
If for some reason you don't want to do that, you can try typecasting
it, like this:
info = (UInt8*)CFDataGetBytePtr(dataRef);
but that is really poor programming style.
Also, you can typecast the assignment,
x = (char*)info;
but once again, that is poor programming style. Is there a reason you
can't make x a UInt8?
~Andrew
On Feb 16, 2006, at 9:29 PM, Steve Cronin wrote:
Folks;
I've got a little nag that the retentive part of me would like to get
out of the way.
As you will soon see, I'm NOT a C guy -- I'm on a journey to become a
Obj-C guy.
I've inherited a snippet of C that causes 2 warnings on clean builds.
Everything works correctly, but it's the only warnings I get in the
project.
And, well, I just don't like them.
Here's the relevant bit:
+ (NSString *)methodZ
{
...
CFDataRef dataRef;
UInt8 *info;
char *x;
... //CFDataGetBytePt returns a pointer to a read-only
byte buffer
info = CFDataGetBytePtr(dataRef); //****warning: assignment
discards qualifiers from pointer target type
if (info) {
...
x = info; //****warning: pointer targets in assignment differ
in signedness
...
I will eventually learn enough C to understand fully how to correct
this BUT in the meantime:
-- Should I just leave well enough alone and get over it?
-- Is there a build flag that might relieve my nettle?
-- Is there an easy change to declarations or code which would soothe
gcc but would not break anything?
(I know you need to see all the code to really answer that but I'll
take suggestions)
Thanks for your gentle acceptance of us Obj-C types who must puzzle on
these sort of things!
Steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden