Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on How to partially pre-process a file, without expanding #include or #embed ?
Post
How to partially pre-process a file, without expanding #include or #embed ?
I'm debugging some "clever" macros (similar to, but not exactly the same as, X macros https://software.codidact.com/posts/293492 ).
Is there a way to get a compiler or a preprocessor (such as gcc or cpp or gpp) to expand only "short" macros and leave "long" preprocessor stuff alone? so if I have something like
#include <enormous_library>
#include <some_other_library>
#embed "embedded_literals.txt"
int main(void){
set_baud_rate(baud_rate)
}
and one of those libraries mentions
#define baud_rate 1200
I want to somehow generate a (relatively short) partially-preprocessed file something like
#include <enormous_library>
#include <some_other_library>
#embed "embedded_literals.txt"
int main(void){
set_baud_rate(1200)
}
The
gcc -save-temps
option tells gcc to expand all the preprocessor stuff into an enormous file with a copy of all the libraries and embedded literals, which can make what I'm looking for hard to find.

1 comment thread