Вопрос

I need to track an error related with the inclusion of header files, I'm suspecting that one or more files have unmatched curly brackets and/or parentheses and I think that would be useful to take a look to the file that pre-processor brings to the compiler; that is the file with all the macro substitution done and all the contents of the headers pasted altogether.

I know that there's a compiler option to save this temporary files to disk, but after googling around I'm not able to found the search string that brings me that information, so I'm asking for help:

What compiler option enables saving into disk the output of the pre-processor?

I'm interested in this option for the following compilers:

  • gcc
  • clang
  • msvc
Это было полезно?

Решение

Most, if not all compilers (all that I've ever used) allow you to "preprocess the source file" by using CC -E myfile.cpp > myfile.i where CC is the name of your compiler (e.g. CL, gcc, g++, clang, clang++, etc.

That will produce large file with everything, and if you have access to an editor that will auto-format your file (like M-x indent-region in Emacs and the like), you can then use that to indent and see where your unmatched braces are.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top