Tuesday, 15 January 2013

Force Whitespace in C Macro? -


I have got the following macro to define a new function after a special naming scheme :

  #define CREATE_HOOK_STUB (func) void ## func_STUB () {/ * some code * /}  

However, the preprocessor always zero and ## Monqub but I clearly want to preserve whitens in that situation.

I know that I can only add some strings to ## monkub user , but this is not what I want. How do I solve this?

I think what you really want:

  #define CREATE_HOOK_STUB (func) void func ## _ STUB () {/ * some code * /}  

but you should also see which additional details are on token pasteing operator Behavior:

When you are using token-paste ('##') or knowing about the stringing ('#') preprocessing operator, one thing is that you have all those cases To work properly in them Sector should be condemned to an additional level.

If you do not do this and the items passed to the token-pasteing operator are the macros themselves, you will get the result, maybe this is probably not what you want ...

  • Link:

No comments:

Post a Comment