一个简单但不容易想明白的问题!精通c的请进!

yifei429 2004-11-21 03:05:39
假设有四个文件:main.c main.h other.c other.h

main.c 中有#include "main.h"
main.h中有#include "other.h"
other.h中有 int max(int,int);
other.c 中有 #include "other.h"和函数体int max(int a,int b){return a;}

现在编译 main.c 后生成main.exe不能使用other.c中的max方法,怎么才能让main中可疑使用max方法.
(不能用在other.h中建类,不能把方法体移到other.h中,有什么别的方法么?比如"宏",配置文件之类方法??)

谢谢了!
...全文
112 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
steadywl 2004-11-21
  • 打赏
  • 举报
回复
extern是声明了一个外部变量,声明为extern的函数可以被其它文件调用
sharkhuang 2004-11-21
  • 打赏
  • 举报
回复
extern int max(int,int);
linking。。。
Leaveye 2004-11-21
  • 打赏
  • 举报
回复
http://dev.csdn.net/develop/article/20/20025.shtm
Leaveye 2004-11-21
  • 打赏
  • 举报
回复
写一个 make 文件
把两个 .c 文件都带进去

69,382

社区成员

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

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