Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preprocessor output on Qt Creator

I am compiling C code in Qt Creator and I need to look at the preprocessor output.

I added the -E flag to the make, but I don't see the *.i files:

mingw32-make.exe -e -w in \qt\qt-build-desktop

Please help.

like image 876
user549099 Avatar asked Dec 20 '10 19:12

user549099


2 Answers

-E is a gcc option, not a make option, so passing it to make won't do anything. Also, using -E works fine for a single file, but will break your build as no proper .o file is generated (it contains the preprocessed source). What works fine though is adding the following to the .pro file:

QMAKE_CXXFLAGS += -save-temps

Now if you build your project, the preprocessed source of source file foo.cpp is kept as foo.ii. (tested with make+gcc on OS X, I'd assume it works for mingw, too).

Edit: Just learned that the equivalent flag for MSVC is

QMAKE_CXXFLAGS += -P
like image 135
Frank Osterfeld Avatar answered Nov 17 '22 10:11

Frank Osterfeld


I could get Qt Creator to generate preprocessed files using one (or more) of the following options in the .pro file:

QMAKE_CFLAGS_DEBUG += -E

QMAKE_CFLAGS_RELEASE += -E

QMAKE_CXXFLAGS_DEBUG += -E

QMAKE_CXXFLAGS_RELEASE += -E

However, one bit of ugliness is that instead of putting the output into .i files it put them into the .o files (which the linker didn't much like...). Since this is presumably a 'one-off' situation for troubleshooting, I didn't look into how to clean that that up.

You may need to rerun 'qmake' before you rebuild, and you'll almost certainly need to run a "Clean Project" build before trying to generate the preprocessed output.

like image 36
Michael Burr Avatar answered Nov 17 '22 10:11

Michael Burr