compile with -E -dD: enum { A, B }; #define B A #define A B+1 int x = A;
This will print something like enum { A, B }; #define B A #define A B+1 int x = A+1; This defines x as 2 instead of 1. Recycle the output bad in and x gets bigger and bigger. Although it doesn't seem to be formally defined that the output of -E -dD is valid source code equivalent to the original, the output is presented as if it is. There are at least two solutions: - present the #define and #undef as comments - suppress macro expansion when -dD is used The ability to suppress macro expansion is a useful feature in its own right and could make some sources more readable, when the intention of -E is simply to flatten the input. -- Summary: gcc -E -dD changes the meaning of source Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: algrant at acm dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38397