📄 macro.c
字号:
//------------------------------------------// 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -