Precedence of -D MACRO and #define MACRO

后端 未结 5 650
情歌与酒
情歌与酒 2021-01-11 14:24

If I have a C file foo.c and while I have given -DMACRO=1 as command line option for compilation. However, if within the header file also I hav

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-11 15:29

    Defines are stored in order the compiler sees them, and when the compiler encounters a new macro with the same name, it overwrites the previous macro with the new one (at least this is the case in gcc). GCC will also give you a warning when this happens.

提交回复
热议问题