[AD] warn_unused_result GCC attribute? |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: alleg-developers@xxxxxxxxxx
- Subject: [AD] warn_unused_result GCC attribute?
- From: Chris <chris.kcat@xxxxxxxxxx>
- Date: Sat, 19 Mar 2005 19:28:14 -0800
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:subject:content-type:content-transfer-encoding; b=oHy3r0fOrPyMaQN9u2ziRw0g8oCAUliXywNdaX9Bmqra6JjREChNgu5XOG1LgMOSggwnD92sywEJ1Yut971gUhHgD9DnWYMgNIVWd8J2pvsqEswlXax0Pa/j8SdoTByRgpH7GdcmTnEImCWMcJ9XWoz2aL6kLq8Mt3mqt7sZgJI=
I ran across this while compiling my new 2.6 kernel. Apparently GCC has
a warn_unused_result attribute that produces a warning when the return
value of a function isn't used (checked or put into a variable).
I don't know what version of GCC introduced it, but I think it'd be
useful for things like install_allegro, set_gfx_mode, etc.. which you
should always check. Normally I wouldn't really like the extra warnings,
but considering the number of newbs that neglect return values, and even
experienced programmers that can let them slip by in error, it might be
better to add it.
I would also like to suggest going through the GCC manual and finding
useful function, variable, and type attributes and adding them where
appropriate, for optimization purposes. Though perhaps this could wait
and just add them as the new API is written up.
The page for function attributes is here:
http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Function-Attributes.html#Function-Attributes
It contains links to the variable and type attribute pages.