Home > C++, VC++ > Expanding macros in a cpp/c file to another file!

Expanding macros in a cpp/c file to another file!

Isn’t it nice to see how our macros get’s expanded into real code, well for this purpose VC++ compiler provides the following compiler switches…

  • /E – Preprocess to stdout
  • /EP – Preprocess to stdout  but no #line this time
  • /P – Preprocess to file*

* This is our man! add this switch to compilation settings of a project’s settings to see *.i files generated for every compiled file in a project.

Just take a look at the size of the file(.i file), it could well be in MB’s, the reason being that all include files also get’s included in the .i file since “#include” is also a preprocessor command.

Take a look at how ASSERT’s, VERIFY’s, BEGIN_MESSAGE_MAP’s get’s expanded.

Have fun learning and digging!

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: