Size of #define values

前端 未结 5 1426
野趣味
野趣味 2021-02-14 04:18

If a value is defined as

#define M_40 40

Is the size the same as a short (2 bytes) or is it as a char (1 byte) or

5条回答
  •  误落风尘
    2021-02-14 05:13

    Preprocessor macros get literally swapped in during the preprocess stage of the compilation.

    For example the code

    #define N 5
    
    int value = N;
    

    will get swapped for

    int value = 5;
    

    when the compiler sees it. It does not have a size of its own as such

提交回复
热议问题