在2个文件中包含相同的头.c

在2个文件中包含相同的头.c,c,header,include,C,Header,Include,c文件:Primitives.c、bloc.c和main.c 和2.h标题:bloc.h和primitives.h 我想处理Primitives.c并使用我制作的bloc.c函数#包括Primitives.c中的“Primitives.h” 在primitives.h中,我有: #ifndef PRIMITIVES_H_ #define PRIMITIVES_H_ #include "bloc.h" #endif h集团: #ifndef BLOC_H_ #define BLOC_H_ ..

c文件:Primitives.c、bloc.c和main.c 和2.h标题:bloc.h和primitives.h 我想处理Primitives.c并使用我制作的bloc.c函数
#包括Primitives.c中的“Primitives.h”
在primitives.h中,我有:

#ifndef PRIMITIVES_H_
#define PRIMITIVES_H_
#include "bloc.h"

#endif
h集团:

#ifndef BLOC_H_
#define BLOC_H_
...
#endif
在primitives.c中:

#include "primitives.h"
printf ("%d", var);
c:我推杆了 int-var=2

问题是,当我编译原语时,它会向我显示。c:
primitives.c:5:9:erreur:string常量前的预期声明说明符或“…”(法语:对不起)

您不能将以下行放入:printf(“%d”,var);
下面的内容包括。它必须放在函数中。

是不是所有的
原语.c
?你是否把stdio包括在内?我把一切都包括在内。。然后bloc.h包含在原语中。h,它是这样工作的吗?就是这样。但我有一个问题;bloc.h我应该把它包含在原语中。h还是原语。c?这取决于你的架构。如果primitives.h使用bloc.h的任何定义,那么它应该包括bloc.h。如果只有primitives.c使用bloc.h的structs/variables/definitions,那么应该在c源代码中包含bloc.h。但是,我建议不要在另一个.h文件中包含头文件.h。