/** * @file di/pp.h * Auxiliary preprocessor helper macros */ #ifndef INCLUDE_DI_PP_H_ #define INCLUDE_DI_PP_H_ #define DI_PP_CONCAT(A, B) A B /* Generate "__FILE__:__LINE__" string at compile time */ #define DI_PP_FILE_LINE \ DI_PP_CONCAT( \ DI_PP_CONCAT( \ __FILE__, \ ":"), \ DI_PP_STRINGIZE(__LINE__)) /* Generate :: string at compile time */ #define DI_PP_COMPONENT_FILE_LINE(component) \ DI_PP_CONCAT( \ DI_PP_CONCAT( \ DI_PP_STRINGIZE(component), \ ":"), \ DI_PP_FILE_LINE) /* Generate ::: string at compile time */ #define DI_PP_COMPONENT_FILE_LINE_MSG(component, msg) \ DI_PP_CONCAT( \ DI_PP_CONCAT( \ DI_PP_COMPONENT_FILE_LINE(component), \ ":"), \ msg) /* * Concatenate preprocessor tokens A and B without expanding macro definitions * (however, if invoked from a macro, macro arguments are expanded). */ #define DI_PP_CAT_NX(A, B) A ## B /* * Concatenate preprocessor tokens A and B after macro-expanding them. */ #define DI_PP_CAT(A, B) DI_PP_CAT_NX(A, B) /* * Turn A into a string literal without expanding macro definitions * (however, if invoked from a macro, macro arguments are expanded). */ #define DI_PP_STRINGIZE_NX(A) #A /* * Turn A into a string literal after macro-expanding it. */ #define DI_PP_STRINGIZE(A) DI_PP_STRINGIZE_NX(A) #endif /* INCLUDE_DI_PP_H_ */