Size of #define values

前端 未结 5 1427
野趣味
野趣味 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:06

    A plain integer is going to be implicitly cast to int in all calculations and assignments.

    #define simply tells the preprocessor to replace all references to a symbol with something else. This is the same as doing a global find-replace on your code and replacing M_40 with 40.

提交回复
热议问题