Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: R1S8K on May 15, 2021, 12:25:32 pm
-
Hi,
I'm using macros and having problem knowing how the code works. So one told me to use a flag that output the expanded generated code.
But I don't know how to use it in codeblocks.
-
We don't have anything integrated for the task.
The easiest way is to do a build of the file, copy the command, modify it and run it in terminal.
If you do this often you can set up a tool for it.
Here are some hints about the flags needed: https://stackoverflow.com/questions/2224334/gcc-dump-preprocessor-defines
-
Sorry I forgot to mention that I use Windows 10.
The easiest way is to do a build of the file, copy the command, modify it and run it in terminal.
Can this be done in Windows ?
-
Yes. The principles and operation is the same on all OSes (mostly).
-
Quick, easy and dirty you can add the -E flag in Project->Build options->Compiler settings->other compiler options
If you hit compile now, the generated object file (with the file ending .o in PROJECT_FOLDER/obj/BUILD_TARGET_NAME/SOURCE_FILE_NAME.o) will contain the preprocessed source. You can open it with any text editor you like. Linking will fail obviously. To compile the program again you have to remove the -E flag and make a rebuild: Build->Rebuild