Re: IDE/ Command Line - failing on ignored return value
Re: IDE/ Command Line - failing on ignored return value
- Subject: Re: IDE/ Command Line - failing on ignored return value
- From: Paul Forgey <email@hidden>
- Date: Thu, 4 May 2006 11:19:32 -0700
On May 4, 2006, at 8:24 AM, glenn andreas wrote:
On May 4, 2006, at 9:59 AM, Tommy Nordgren wrote:
Is there any command line option/ IDE setting that can be used to
fail the build,
or at least give a warning if return values are ignored in C++ and C?
Are you really sure you want such a thing? Are you, for example,
using the return values from all of your printfs? strcat/strcpys?
memsets? fclose?
Basically almost all of the standard C library routines return a
value - making sure to not ignore them would, at best, needlessly
clutter your app (or alternately, flood your build log with "false
positive" warning messages, obscuring any useful ones).
(I vaguely seem to remember it is because of this that such a
warning does not exist, but that's one of those "back in the
distant past" memories)
For specific cases, however, I believe you can do something like:
void* foo(int param1, int param2) __attribute__
((__warn_unused_result__));
and thus indicate that this specific routine's return value should
not be ignored (as opposed to checking all of them)
I'm not certain gcc has a -W option for this. Lint does this type of
thing and is why in a lot of unix code you'll see statements like:
(void) close (fd);
..as an explicit way to tell both humans and super anal code checking
tools you are ignoring the result on purpose.
_______________________________________________
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