1. 程式人生 > >definition to expand macro then apply to pragma message

definition to expand macro then apply to pragma message

pragma macro

/* Some test definition here */

#define DEFINED_BUT_NO_VALUE

#define DEFINED_INT 1

#define DEFINED_STR "ABC"


/* definition to expand macro then apply to pragma message */

#define VALUE_TO_STRING(x) #x

#define VALUE(x) VALUE_TO_STRING(x)

#define VAR_NAME_VALUE(var) #var "=" VALUE(var)


/* Some example here */

#pragma message(VAR_NAME_VALUE(NOT_DEFINED))

#pragma message(VAR_NAME_VALUE(DEFINED_BUT_NO_VALUE))

#pragma message(VAR_NAME_VALUE(DEFINED_INT))

#pragma message(VAR_NAME_VALUE(DEFINED_STR))


definition to expand macro then apply to pragma message