一个很蛋疼的函数定义方式~

kitcaii kitcaii 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

/**************** list.h ********************/
typedef struct {
void **item;
int num;
} LIST;

#ifdef WIN32

#ifdef __cplusplus
extern "C" {
#endif
extern int AppendItem(LIST *pList,void *pItem);

#ifdef __cplusplus
}
#endif

#else
extern int AppendItem();

#endif


/**************** list.c ********************/
int AppendItem(pList,pItem)
LIST *pList;
void *pItem;
{
void **pItems;
if(pList->num>0 && pList->num%LIST_BLOCK_SIZE==0)
{
pItems=realloc(pList->items,
(pList->num+LIST_BLOCK_SIZE)*sizeof(void*)
);
if(pItems==NULL)
return(-1);
pList->item = pItems;
}
pList->item[pList->num] = pItem;
pList->num++;
return(0);
}


1.函数定义部分中函数头这么写是什么意思?
2.如果没有定义WIN32,函数声明为无参型的,函数定义却是有参型的,怎么保证正确调用?
...全文

相关推荐

评论 9
收藏 已收藏
分享
返回顶部
kitcaii
C++ 语言 65,214 成员 250,514 内容