由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 问个两个.h文件互相include的问题
相关主题
弱问一个ifdef 和ifndef怎样include一个函数
c++,这种做法不行?弱问C++一个问题 一直不解
两个class的交叉引用问题#ifdef, #ifndef 这些 preprocessor 应该叫什么呀?
最基本的C语言编程问题请教C++ interdependence question
弱问c++里有没有NULL这个keyword?global variable usage question in C++
另一个Fortran 问题请教一个弱弱问题,关于#include的pathname
又一个初级问题: C++中多如牛毛的#define格式Why should i include .cpp instead of .h
C 里面有办法永久改变一个指针的属性吗?gcc 编译的时候要包括 header source file 吗?
相关话题的讨论汇总
话题: ifndef话题: endif话题: include话题: make话题: project
进入Programming版参与讨论
1 (共1页)
l******d
发帖数: 530
1
最近拿到别人的一个project,是2.4.18内核的kernel module。发现里面有两个头文件, a.h, b.h,大致如下
a.h
#ifndef A_H
#define A_H
...
#ifdef B_H
#include "b.h"
#endif B_H
...
#endif
b.h
#ifndef B_H
#define B_H
...
#include "a.h"
...
#endif
make bzImage的时候报错
Circular b.h < a.h dependency dropped
按理说这样互相include是不行的吧?但这个project别人拿来发了paper的,我搞不懂了
X****r
发帖数: 3557
2
The compiler should be okay with that because when b.h is
included for the second time it just does nothing thanks to
the #ifndef guard. However, 'make' wouldn't be able to
generate dependencies automatically from this kind of structure,
and this is the error you're seeing.

【在 l******d 的大作中提到】
: 最近拿到别人的一个project,是2.4.18内核的kernel module。发现里面有两个头文件, a.h, b.h,大致如下
: a.h
: #ifndef A_H
: #define A_H
: ...
: #ifdef B_H
: #include "b.h"
: #endif B_H
: ...
: #endif

t****t
发帖数: 6806
3
actually make should be ok, since it's .o depends on .h, not .h depends on .
h. regular make use cc to generate dependency anyway... i guess he's using
some special make.

【在 X****r 的大作中提到】
: The compiler should be okay with that because when b.h is
: included for the second time it just does nothing thanks to
: the #ifndef guard. However, 'make' wouldn't be able to
: generate dependencies automatically from this kind of structure,
: and this is the error you're seeing.

l******d
发帖数: 530
4
我没说详细,这个project是一个kernel module,挺老的一个project,2.4.18的。我在
make bzImage时出来上面的报错,但最后好像还是make完了

.

【在 t****t 的大作中提到】
: actually make should be ok, since it's .o depends on .h, not .h depends on .
: h. regular make use cc to generate dependency anyway... i guess he's using
: some special make.

y***d
发帖数: 2330
5
so it was just a warning?
It is strange (and pointless) to use B_H the way in a.h, however

我在

【在 l******d 的大作中提到】
: 我没说详细,这个project是一个kernel module,挺老的一个project,2.4.18的。我在
: make bzImage时出来上面的报错,但最后好像还是make完了
:
: .

l********a
发帖数: 1154
6
a.h里面不应该是#ifndef B_H吗?怎么写的是#ifdef B_H呢?
不过我也是二把刀
l******d
发帖数: 530
7
a.h开头和结尾有#ifndef A_H和#endif的,原帖为了省事没敲进去,现在补上了

【在 l********a 的大作中提到】
: a.h里面不应该是#ifndef B_H吗?怎么写的是#ifdef B_H呢?
: 不过我也是二把刀

b***i
发帖数: 3043
8
还是出问题啊,你再仔细想想

【在 l******d 的大作中提到】
: a.h开头和结尾有#ifndef A_H和#endif的,原帖为了省事没敲进去,现在补上了
1 (共1页)
进入Programming版参与讨论
相关主题
gcc 编译的时候要包括 header source file 吗?弱问c++里有没有NULL这个keyword?
is there any lib can read .Z file in c++/c program?另一个Fortran 问题
怎样清理不要的C代码又一个初级问题: C++中多如牛毛的#define格式
makefile 里面那个-D flags的问题C 里面有办法永久改变一个指针的属性吗?
弱问一个ifdef 和ifndef怎样include一个函数
c++,这种做法不行?弱问C++一个问题 一直不解
两个class的交叉引用问题#ifdef, #ifndef 这些 preprocessor 应该叫什么呀?
最基本的C语言编程问题请教C++ interdependence question
相关话题的讨论汇总
话题: ifndef话题: endif话题: include话题: make话题: project