rcutils  master
C API providing common utilities and data structures.
macros.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


#define RCUTILS_WARN_UNUSED   __attribute__((warn_unused_result))
#define RCUTILS_THREAD_LOCAL   _Thread_local
#define RCUTILS_UNUSED(x)   (void)(x)
#define RCUTILS_ATTRIBUTE_PRINTF_FORMAT(format_string_index, first_to_check_index)   __attribute__ ((format(printf, format_string_index, first_to_check_index)))

Macro Definition Documentation


#define RCUTILS_WARN_UNUSED   __attribute__((warn_unused_result))


#define RCUTILS_THREAD_LOCAL   _Thread_local


#define RCUTILS_STRINGIFY_IMPL (   x)    #x




#define RCUTILS_UNUSED (   x)    (void)(x)


#define RCUTILS_ATTRIBUTE_PRINTF_FORMAT (   format_string_index,
)    __attribute__ ((format(printf, format_string_index, first_to_check_index)))

Macro to annotate printf-like functions which are relying on a format string and a variable number of arguments. This enables GCC to emit warnings if dangerous patterns are detected. See GCC documentation for details: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

For the following function: int snprintf(char *str, size_t size, const char *format, ...); ^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ARG 1 ARG 2 ARG 3 ARG 4 format string first optional argument

format_string_index value would be 3, first_to_check_index value would be 4.

IMPORTANT: the first argument has an index of ONE (not zero!).

format_string_indexindex of the format string passed to the function
first_to_check_indexindex of the first "optional argument"