How to see what a file looks like after preprocessing?

How to check the preprocessing results? For example, let's say I have the following code:

#define CONCATENATE(X, Y) X ## Y
#define STRING_1 First
#define STRING_2 Second
#define STRING_3 CONCATENATE(STRING_1, STRING_2)

Is there any way to make sure it STRING_3will be expanded to FirstSecondlater in the program?

+3
source share
2 answers

Each compiler must provide a switch to save pre-processed code.

  • gcc: -E
  • MS Visual Studio: Keep preprocessed filesin settings or /Pswitch

For other compilers, I'm sure you will find a suitable switch in the documentation

+8
source

I think it is best to run the C ++ file under g++ -E <file> -o <file>.out, and then check the result this way.

, - , , .

+2

Source: https://habr.com/ru/post/1792908/


All Articles