decomp-permuter
decomp-permuter copied to clipboard
Macro preserval shouldn't depend on the order of macros
#define A B
#define B C
A
with import.py --preserve-macros=A will at the start of preprocess_c_with_macros
create the temporary file
_permuter define A B
#define B C
A
and run cpp on that in order to expand macros in the definition of A before turning it back into a #define
, but this fails because the define for B comes after that of A. When you compile the file normally it works, however, because macro expansion is lazy.
Should probably fix this by first stripping comments, and then moving all macro definitions to the top.
If there are #undef
s that makes things harder; in principle unfixable if there are macros that get undef'd and redefined and are referenced from a macro that changes meaning over time (not that we care about that case).