Skip to content

Instantly share code, notes, and snippets.

@kaityo256
Created July 28, 2020 10:26
Show Gist options
  • Save kaityo256/3b80e0f044c4ff1b61936bdda4b579c9 to your computer and use it in GitHub Desktop.
Save kaityo256/3b80e0f044c4ff1b61936bdda4b579c9 to your computer and use it in GitHub Desktop.
Redefined macro
#include <cstdio>
#define A 1
#define B 1
#define A 1 // No warning
#define B 2 // test.cpp:7:0: warning: "B" redefined
int main() {
printf("%d %d\n", A, B);
}
@kaityo256
Copy link
Author

$ g++ test.cpp
test.cpp:7:0: warning: "B" redefined
 #define B 2 // test.cpp:7:0: warning: "B" redefined

test.cpp:4:0: note: this is the location of the previous definition
 #define B 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment