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的,原帖为了省事没敲进去,现在补上了
|