5.14.3.7 The #pragma Printf_check Directive
Certain library functions accept a format string followed by a variable
number of arguments in the manner of printf()
. Although the format string
is interpreted at runtime, it can be compile-time checked for consistency with the
remaining arguments.
This directive enables this checking for the named function, for example
the system header file <stdio.h>
includes the directive:
#pragma printf_check(printf) const
to enable this checking for printf()
. You can also use
this for any user-defined function that accepts printf-style format strings.
The qualifier following the function name is to allow automatic conversion
of pointers in variable argument lists. The above example would cast any pointers to
strings in RAM to be pointers of the type (const char *
).
Note that the warning level must be set to -1 or below for this option to have any visible effect (see 4.6.4.2 Warn Option).