写一个.h文件

filipesi 2010-04-26 02:39:43
这个问题里的那个程序wordpool.c,
如果我想写个wordpool.h
是不是这样写?

#define MAX_WORDS 200
#define MAX_SIZE 10

typedef struct _wordPool {
int counter;
char word[MAX_SIZE];
} WordPool;

int findword(const char *wt);
void add(const char *wp);
void print() ;

...全文
217 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
请叫我卷福 2010-04-27
  • 打赏
  • 举报
回复
保证C和C++的混编能够正常链接
ding~
gary_cai 2010-04-27
  • 打赏
  • 举报
回复

2楼
mymtom 2010-04-26
  • 打赏
  • 举报
回复
楼主的写法是正确的。
改为二楼的写法就符合实际项目要求了。
icansaymyabc 2010-04-26
  • 打赏
  • 举报
回复
写法正确
尹成 2010-04-26
  • 打赏
  • 举报
回复
楼主的写法是正确的
但最好在最前面加 #program once 避免被多个文件引用的时候 重复定义


UP
Lee723 2010-04-26
  • 打赏
  • 举报
回复
#program once 的移植性不好吧!
#ifndef
#define

#endif
zuiyuezhou888 2010-04-26
  • 打赏
  • 举报
回复
楼主的写法是正确的
但最好在最前面加 #program once 避免被多个文件引用的时候 重复定义
localxiao 2010-04-26
  • 打赏
  • 举报
回复
保证C和C++的混编能够正常链接
znyu2005 2010-04-26
  • 打赏
  • 举报
回复

#ifdef __cplusplus
}
#endif

请问这个是什么意思???没有见过,请问高手能解释一下吗?为什么这样子写
liangchencf 2010-04-26
  • 打赏
  • 举报
回复
最好是

#ifndef _WORDPOOL_H
#define _WORDPOOL_H

#ifdef __cplusplus
extern "C" {
#endif

#define MAX_WORDS 200
#define MAX_SIZE 10

typedef struct _wordPool {
int counter;
char word[MAX_SIZE];
} WordPool;

int findword(const char *wt);
void add(const char *wp);
void print() ;

#ifdef __cplusplus
}
#endif
#endif /*_WORDPOOL_H*/

避免循环包含和被C++模块调用
huanmie_09 2010-04-26
  • 打赏
  • 举报
回复
可以的.

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧