Mbed OS Reference
Loading...
Searching...
No Matches
preprocessor macros

Macros

#define MBED_CONCAT(a, b)   MBED_CONCAT_(a, b)
 MBED_CONCAT Concatenate tokens together. More...
 
#define MBED_STRINGIFY(a)   MBED_STRINGIFY_(a)
 MBED_STRINGIFY Converts tokens into strings. More...
 
#define MBED_STRLEN(a)   MBED_STRLEN_(a)
 MBED_STRLEN Reports string token length. More...
 
#define MBED_COUNT_VA_ARGS(...)   GET_NTH_ARG_(__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
 MBED_COUNT_VA_ARGS(...) Reports number of tokens passed. More...
 

Detailed Description

Macro Definition Documentation

◆ MBED_CONCAT

#define MBED_CONCAT (   a,
 
)    MBED_CONCAT_(a, b)

MBED_CONCAT Concatenate tokens together.

Note
Expands tokens before concatenation
// Creates a unique label based on the line number
int MBED_CONCAT(UNIQUE_LABEL_, __LINE__) = 1;
#define MBED_CONCAT(a, b)
MBED_CONCAT Concatenate tokens together.

Definition at line 39 of file mbed_preprocessor.h.

◆ MBED_STRINGIFY

#define MBED_STRINGIFY (   a)    MBED_STRINGIFY_(a)

MBED_STRINGIFY Converts tokens into strings.

Note
Expands tokens before stringification
// Creates a string based on the parameters
const char *c = MBED_STRINGIFY(This is a ridiculous way to create a string)
#define MBED_STRINGIFY(a)
MBED_STRINGIFY Converts tokens into strings.

Definition at line 53 of file mbed_preprocessor.h.

◆ MBED_STRLEN

#define MBED_STRLEN (   a)    MBED_STRLEN_(a)

MBED_STRLEN Reports string token length.

Note
Expands tokens before calculating length
// Get string length
const int len = MBED_STRLEN("Get the length")
#define MBED_STRLEN(a)
MBED_STRLEN Reports string token length.

Definition at line 67 of file mbed_preprocessor.h.

◆ MBED_COUNT_VA_ARGS

#define MBED_COUNT_VA_ARGS (   ...)    GET_NTH_ARG_(__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)

MBED_COUNT_VA_ARGS(...) Reports number of tokens passed.

Note
Token limit is 16
// Get number of arguments
const int count = MBED_COUNT_VA_ARGS("Address 0x%x, Data[0] = %d Data[1] = %d", 0x20001234, 10, 20)
#define MBED_COUNT_VA_ARGS(...)
MBED_COUNT_VA_ARGS(...) Reports number of tokens passed.

Definition at line 81 of file mbed_preprocessor.h.