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?

29th Aug 2017, 9:14 AM
Bluebear
Bluebear - avatar
6 odpowiedzi
+ 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...
29th Aug 2017, 10:02 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 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
30th Aug 2017, 12:41 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
You can run "gcc -E mycode.cpp" to do nothing put expand preprocessor definitions, if you are using gcc.
29th Aug 2017, 10:24 AM
Schindlabua
Schindlabua - avatar
+ 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.
29th Aug 2017, 7:39 PM
Bluebear
Bluebear - avatar
+ 1
@Kinshuk Vasisht thank you.it been solved. just add /P to preprocessor and it will create a file end with .i
30th Aug 2017, 7:47 AM
Bluebear
Bluebear - avatar
0
@Schindlabua i using visual studio 2015,how can i expand macro by a simple way?
29th Aug 2017, 7:25 PM
Bluebear
Bluebear - avatar