Size of #define values

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

    The preprocessor just does simple text substitution, so the fact that your constant is in a #define doesn't matter. All the C standard says is that "Each constant shall have a type and the value of a constant shall be in the range of representable values for its type." C++ is likely to not vary too much from that.

提交回复
热议问题