C—中的宏扩展;检索无符号32位字
下面的代码段是如何工作的?里面有什么?Eclipse说IN代表“宏扩展”:C—中的宏扩展;检索无符号32位字,c,types,macros,struct,buffer,C,Types,Macros,Struct,Buffer,下面的代码段是如何工作的?里面有什么?Eclipse说IN代表“宏扩展”: UWORD32 (*get_u32)(IN UWORD8 *buffer_ptr); /* Gets unsigned 32bit word */ /* from the buffer */ 上述代码是结构的一部分。是这样使用的 struct my struct s; UWORD8* buf; s->get_u32
UWORD32 (*get_u32)(IN UWORD8 *buffer_ptr); /* Gets unsigned 32bit word */
/* from the buffer */
上述代码是结构的一部分。是这样使用的
struct my struct s;
UWORD8* buf;
s->get_u32(buf);
它是如何工作的?我猜中的
是#将d定义为const
:
#define IN const // input parameters are const
get_u32
只是一个函数指针-该函数接受单个参数(指向UWORD8
)并返回一个UWORD32
,您甚至可以在中声明为“nothing”
在这种情况下,它只会使代码更具可读性:)
还提到系统(Linux/window?)。。。我在Linux的库文件中搜索'IN',没有找到这样的宏。IN的定义是:/*用IN声明的参数,将用于保存输入值*/#define IN没有常量…这意味着什么?这对含义没有太大影响-只是一种符号方便。在本例中,
中的实际上只是一个注释。
#define IN
#define OUT
void func ( IN param_t param1, /* INPUT PARAM */
IN param_t param2, /* INPUT PARAM */
OUT param_t *param3); /* OUTPUT PARAM */