#include <stdio.h>
#define MY_INT 7777
#define STR(R) #R
#define STR2(R) STR(R)

enum MyType{
    MyType_NULL,
    MyType_One,
    MyType_Two
};

int main()
{
    printf("%s\n", STR(MyType_One));
    printf("%s\n", STR(HELLO_WORLD));
    printf("%s\n", STR(MY_INT));
    printf("%s\n", STR2(MY_INT));
    const int arr[] = {1,2,3};
    arr[1] = 4;     // error: assignment of read-only location ‘arr[1]’
    return 0;
}

输出:

MyType_One
HELLO_WORLD
MY_INT
7777

参考:

  1. c++中#与##的作用