GNU

如何在Preprocessor列印定義的數值


參考資訊:
1. how-do-i-show-the-value-of-a-define-at-compile-time

main.c

#include <stdio.h>

#define TEST    1234

#define STR(x)  #x
#define XSTR(x) STR(x)
#pragma message "VAL:" XSTR(TEST)

int main(int argc, char **argv)
{
    return 0;
}

編譯測試

$ gcc main.c -o gg
    main.c:7:9: note: #pragma message: VAL:1234


返回上一頁