#define many times without #undef,is it legal?

后端 未结 4 857
你的背包
你的背包 2020-12-21 20:22

For example, I define AA for three times, is it legal?:

#include
#define AA 10
#define AA 20
#define AA 30
int main() {
    printf(\"         


        
4条回答
  •  旧巷少年郎
    2020-12-21 20:49

    Lets start by correcting your printf to something useful: printf("%d", AA);

    Compiling it with gcc will produce two warnings that "AA" is redefined. Warnings are really important and should be avoided in C, but the result will be as expected (30).

提交回复
热议问题