Make your own free website on
« February 2007 »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28
You are not logged in. Log in

Programming Tips
Monday, 12 February 2007
Auto expanding #define's and #include's
Mood:  a-ok
Topic: VC++

Did you ever feel the need for having all the macros defined in a file to get expanded automatically...

Now you may wonder why do we need such a thing, one reason could be to learn the intricacies of these macros.


Now the question is how to do this... Here is nice little compiler option...

/P - PreProcess to File
/EP - Preprocess to stdout, no #line
/E - Preprocess to stdout

Now here is how we do this...

cl /P CMyDlg.cpp

This command will create a CMyDlg.i file which contains the entire source contents of CMyDlg.cpp along with all include files expanded with it's contents and all macros expanded to actual code.

But before all this just look at the size of CMyDlg.i. It could be in MB's. :)) But our source file's size was in KB's right? ;)

Well this shows the real thing that's going on.

I would like to give you a task, go through all the compiler options and find out what they do. Maybe take a printout of these options and hang it somewhere near to you, so that you can have a quick look at all compiler options, and understand what they do.

Hope this helps you and me to learn.

Posted by Nibu babu thomas at 2:53 PM
Updated: Monday, 26 February 2007 5:12 PM

View Latest Entries