0
how to show codes after preprossor?
I am used to use macro. But now i wanna show my codes to others,how to translate my codes to normal form not include macro by a simple code?
6 Answers
+ 4
@Bluebear
Share some codes which you want to convert.
Ill be able to help you in a better way then...
For normal defines of constants, you may simply use constants of the type you wish to store.
Eg -
#define PI 3.14159 == const double PI = 3.14159;
And for functions:
#define sqr(x) x*x
==
inline double sqr(double x)
{ return x*x; }
Here, inline indicates that the function is to be copied before evaluation, like a macro. But, using inline is safer and convenient...
+ 4
@Bluebear
Sorry, I wasn't able to understand what you wanted to do.
Try this:
https://msdn.microsoft.com/en-us/library/8z9z0bx6(VS.80).aspx
+ 1
You can run "gcc -E mycode.cpp" to do nothing put expand preprocessor definitions, if you are using gcc.
+ 1
@Kinshuk Vasisht
useful suggestion.
but i just wana expand my macro rather than rewrite them.
more macros,less codes,very very cool.
inline add codes,i dont like it.
+ 1
@Kinshuk Vasisht
thank you.it been solved.
just add /P to preprocessor and it will create a file end with .i
0
@Schindlabua
i using visual studio 2015,how can i expand macro by a simple way?