https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93677
Bug ID: 93677 Summary: Create a warning for duplicate macro definition Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: vincent-gcc at vinc17 dot net Target Milestone: --- There should be a warning for duplicate macro definition (i.e. with the same value), such as #define FOO 1 #define FOO 1 Such code is valid, but a duplicate macro definition may occur inadvertently in the code, and it does not ease code maintenance and readability. For instance, one definition may occur in some header file, and another one in a .c file for some completely different meaning, while the value in both definitions is the same only by chance. Such code introduces confusion and makes code evolution more error prone: if for some reason one of the values needs to be changed, the macro name needs to be changed too (this is what should have been done earlier, but it would have been better to detect the issue as soon as the duplicate macro definition was added). For function-like macros, issues may also occur when one wants to change the implementation, keeping the same behavior: the change in one of the definitions becomes invalid. Thus it is better to define such macros in only one place, and the warning would detect a failure to do that. The switch could be combined with the request in PR83773 (which is about macro redefinition with a different value).