Groups    |     Jobs    |      User Space 

Hello, pls   log in or   register
current location:   up9rade > groups > my career
关于C++ 使用Macro funciton的问题

20080123 20:10:53   from: Lorry Astra


1.大家知道C++中使用类似C中的Macro会带来问题,那么这个问题就是Macro中会隐藏一些bug。我的问题是之所以大家认为这些bug不容易被察觉是否是因为Macro本身可以逃脱Compile对它的逻辑检查;而Macro直接被preprocessor处理了。
2.Macro function不能被用作类成员的function,这是为什么?

谢谢
------------------------------------------------------------------------------------------------------------


20080124 09:24:58:   freedo    quote    
Reply on behalf of one of my colleague from ATC Beijing:

Actually Macro is not that problematic, if you use it correctly
It will be processed in the beginning of compilation
So I think it's not Macro which brings the trouble. It is actually the people used the Macro in wrong place, maybe

So I don't know what he means :" Macro can escape the gramma checking by compiler"
That doesn't make any sense
The complier will validate the code after replacement of all Macros

Macro function doesn't make any sense also
I would recommend you to treat Macro as the replacement directives

I don't think if I describes well
But those two questions doesn't seems valuable in my humble opinion



20080124 09:27:47:   freedo    quote    
Useful macros needs careful design and deep understanding of the compliation.
Normal coder won't use it too often. It's not easy to control. But defnitely not the reason listed above


I want to say something...

Input autho code, click on image to change another code: