Win32:Token-Pasting Operator (##)

mac2022-06-30  25

#define paster( n ) printf_s( "token" #n " = %d", token##n ) int token9 = 9;

If a macro is called with a numeric argument like

  复制 paster( 9 );

the macro yields

  复制 printf_s( "token" "9" " = %d", token9 );

which becomes

  复制 printf_s( "token9 = %d", token9 ); Example
  复制 // preprocessor_token_pasting.cpp #include <stdio.h> #define paster( n ) printf_s( "token" #n " = %d", token##n ) int token9 = 9; int main() { paster(9); } token9 = 9

转载于:https://www.cnblogs.com/shenchao/archive/2013/06/08/3125651.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)