2019-05-03 17:49:57 -04:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
General Macros
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
#ifndef COMMON_MACRO_H
|
|
|
|
#define COMMON_MACRO_H
|
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Convert the parameter to a zero-terminated string
|
|
|
|
|
2019-05-13 18:05:54 -04:00
|
|
|
Useful for converting non-string types (e.g. int) to strings for inclusion in messages.
|
2019-05-03 17:49:57 -04:00
|
|
|
***********************************************************************************************************************************/
|
|
|
|
#define STRINGIFY_HELPER(param) #param
|
|
|
|
#define STRINGIFY(param) STRINGIFY_HELPER(param)
|
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Glue together a string/macro and another string//macro
|
|
|
|
|
|
|
|
Useful for creating function names when one or both of the macro parameter needs to be converted to a macro before concatenating.
|
2020-03-30 20:52:57 -04:00
|
|
|
common/type/object.h has numerous examples of this.
|
2019-05-03 17:49:57 -04:00
|
|
|
***********************************************************************************************************************************/
|
|
|
|
#define GLUE_HELPER(param1, param2) param1##param2
|
|
|
|
#define GLUE(param1, param2) GLUE_HELPER(param1, param2)
|
|
|
|
|
2019-05-13 18:05:54 -04:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
If param2 > param1 then assign it to param1
|
|
|
|
|
2019-08-26 12:05:36 -04:00
|
|
|
Useful for ensuring coverage in cases where compared values may be always ascending or descending.
|
2019-05-13 18:05:54 -04:00
|
|
|
***********************************************************************************************************************************/
|
|
|
|
#define MAX_ASSIGN(param1, param2) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
if (param2 > param1) \
|
|
|
|
param1 = param2; \
|
|
|
|
} \
|
|
|
|
while (0)
|
|
|
|
|
2019-05-03 17:49:57 -04:00
|
|
|
#endif
|