 |
nonnull |
Syntax: nonnull [(param1[, param2[, ...]])]
The nonnull
attribute specifies that some function parameters should
be non-null pointers. For instance, the declaration:
extern void *
my_memcpy (void *dest, const void *src, size_t len)
__attribute__((nonnull (1, 2)));
causes the compiler to check that, in calls to my_memcpy
,
arguments dest and src are non-null. If the compiler
determines that a null pointer is passed in an argument slot marked
as non-null, and the '-Wnonnull' option is enabled, a warning
is issued. The compiler may also choose to make optimizations based
on the knowledge that certain function arguments will not be null.
If no argument index list is given to the nonnull
attribute,
all pointer arguments are marked as non-null. To illustrate, the
following declaration is equivalent to the previous example:
extern void *
my_memcpy (void *dest, const void *src, size_t len)
__attribute__((nonnull));