Suppose I have simple program like
// Souce.c
#define greater(a, b) ((a) > (b) ? a : b);
int main()
{
greater(10, 20);
return 0;
}
// Source.c ends here
Now how to create a file which will show me expanded macros in this course file?
Very simple add /E and /P to project options. In the same file as that of Source.c a new file Source.i will be generated.
I am writing here contents of Source.i to understand it's contents -
# Source.i
#line 1 ...
int main()
{
((10) > (20) ? 10 : 20);;
return 0;
}
# Source.i ends here
Hope this post is of help
I just checked with Visual studio 2008.
ReplyDeleteGo to Project (Menu) -> select properties.
This will open one options window.
On Right hand side there is tree -
Expand confugeration properties
Expand C/C++ (under configeration properties)
Select Command Line (Under C/C++)
On right side it shows "All options"
and below it "Additional Options"
Add /E /P in "Additional Options" text field.
This is interesting.. I like Visual studio for all these options it provides.
ReplyDelete