The attached patch introduces a new header file:
nsattributes.h. It contains defines for gcc attributes
(see gcc docs) which allow you to more accurately
describe your intentions when specifying functions,
types and variables.
For example, you can specify that a function takes
printf like arguments, in which case gcc will check
their types and number for you. Or, you can specify
that certain parameters should never be null.
I've annotated some of the source in a series of small,
seperate patches. If you look at the considerably
cleaner output of a compile with the patches applied,
you'll see a couple of obvious bugs which should be fixed.
Bigger gains in safety could likely be had by judicious
use of the _nsnonnull and _nswarnunused attributes.
The _nsdeprecated attribute would help module writers alot.
In the future, some of the splint (see: splint.org)
markup could be added. I'm sure there are bugs in the
code that this would turn up...
gcc attributes support
check format strings
malloc optimization
Logged In: YES
user_id=21885
FWIW, using gcc-specific features in our code means not
being able to build with, for example, Sun Forte compiler on
Solaris, which for 64-bit builds may be desirable. Or
possibly using the Intel C compiler on x86/EM64T.
Logged In: YES
user_id=21885
(It looks like the patches are all "safe" in that they
become no-ops on non-gcc builds. Cool.)
Logged In: YES
user_id=522678
Adding nsattributes.h caused two problems with the windows
build (non-gcc).
1) I think the top of nsattributes.h is missing something like:
#else
# define __GNUC_PREREQ(maj, min) 0
2) Microsoft Visual C++ doesn't support variadic macros.
This annoying situation is finally addressed in Visual
Studio 2005 but that's still in beta. In the meantime, the
win32 build can't handle the definition (or any uses, though
I don't see any yet) of this line:
# define _nsnonnull(...)
Logged In: YES
user_id=20624
Fixed compile with non-gcc compiler including on windows.