macro.c

来自「cygwin下的包含各种c基本操作的demo程序」· C语言 代码 · 共 45 行

C
45
字号
//------------------------------------------//          to test the define and the -> operation//------------------------------------------#include "my_common.h"void dummy_str_fun(char *);#define a2i(x)  do{printf("a2i:%s\n",x);}  while(0)//#define a_fun_str->f_p(x) dummy_str_fun(x)  //this will not work ????????extern void fun_p(char *);#ifdef __cplusplusextern "C"   {#endifvoid dummy_str_fun(char *str){NULL;}void macro_test(){     char *str = "the macro test str";     fun_str *a_fun_str = (fun_str*)malloc(sizeof(fun_str));      a_fun_str->aa = 10;     a_fun_str->f_p =fun_p;               printf("the value of a_fun_str is %x\n",a_fun_str);      printf("the value of aa is %d \n",*a_fun_str);                       EXAM_ASSERT( 10 == a_fun_str->aa );     //printf( "the value of aa is %d",a_fun_str->aa);     a_fun_str->f_p("yeah");     a2i(str);     a2i("2:good");          return;}void dummy_printf(char *fmt,...){ NULL;}#ifdef __cplusplus}#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?