CARB_PRINTF_FUNCTION

Defined in carb/Defines.h

CARB_PRINTF_FUNCTION(fmt_ordinal, args_ordinal)

Requests that the compiler validate any variadic arguments as printf-style format specifiers, if supported by the compiler. Causes a compilation error if the printf-style format specifier doesn’t match the given variadic types.

Note

The current implementation is effective only when CARB_COMPILER_GNUC

is non-zero. The Windows implementation does not work properly for custom printf-like function pointers. It is recommended where possible to use a “fake

printf” trick to force the compiler to evaluate the arguments:

if (0) printf(fmt, arg1, arg2); // Compiler will check but never execute.

Parameters
  • fmt_ordinal – The 1-based function parameter receiving the printf-style format string.

  • args_ordinal – The 1-based function parameter receiving the first variadic argument.