| ▲ | jacquesm 2 days ago | |
That's a great question. I found this on SO: https://stackoverflow.com/questions/59553295/selective-macro... Maybe that would work for your use case? What I like about your question is that I always assumed the answer was a hard 'no' but that appears not to be the case. | ||
| ▲ | piaste a day ago | parent [-] | |
It was a theoretical question. It's not the first time I hear the complaint '$previous_dev left a bunch of unmaintainable macro tricks in a C codebase' and I thought, since those macros get expanded as part of the compilation process, surely it should be possible to intercept and capture the expanded version? Even if a whitelist is not available (the SO question involves a particular C++ preprocessor and may not apply to others), a hacky approach might be to comment out all the #defines in the codebase, uncomment the ones you want to get rid of, and then run the full preprocessor task on it. Ugly but probably doable for a one-time refactoring. | ||