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

Go to the source code of this file.

Macros

#define RCUTILS_WARN_UNUSED   __attribute__((warn_unused_result))
 
#define RCUTILS_THREAD_LOCAL   _Thread_local
 
#define RCUTILS_STRINGIFY_IMPL(x)   #x
 
#define RCUTILS_STRINGIFY(x)   RCUTILS_STRINGIFY_IMPL(x)
 
#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

◆ RCUTILS_WARN_UNUSED

#define RCUTILS_WARN_UNUSED   __attribute__((warn_unused_result))

◆ RCUTILS_THREAD_LOCAL

#define RCUTILS_THREAD_LOCAL   _Thread_local

◆ RCUTILS_STRINGIFY_IMPL

#define RCUTILS_STRINGIFY_IMPL (   x)    #x

◆ RCUTILS_STRINGIFY

#define RCUTILS_STRINGIFY (   x)    RCUTILS_STRINGIFY_IMPL(x)

◆ RCUTILS_UNUSED

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

◆ RCUTILS_ATTRIBUTE_PRINTF_FORMAT

#define RCUTILS_ATTRIBUTE_PRINTF_FORMAT (   format_string_index,
  first_to_check_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!).

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