C++ 头文件中已经用#include 包含了类型声明的头文件,为什么还会提示该类型没有声明(error: 'cfdemCloudIB' has not been declared)?已经排除了类之间互相包含的可能性;还有其他可能情况吗?
ringa_lee
Are you compiling under linux or window?
If you are compiling under Linux, did you forget to add the path of the header file you included under the -I option? The compilation principle under window is similar.
-I
The order in which header files are included will also have an impact.
Give me a chestnuta.h
#ifndef INT define INT32 int #endif
b.h
#define INT long
m.c
#include "b.h" #include "a.h" INT32 x = 0; // 这里将报错,因为INT32实际上是没有定义的
For the above code, the two header files contain familiar ones and can be reversed.
Are you compiling under linux or window?
If you are compiling under Linux, did you forget to add the path of the header file you included under the
-I
option? The compilation principle under window is similar.The order in which header files are included will also have an impact.
Give me a chestnut
a.h
b.h
m.c
For the above code, the two header files contain familiar ones and can be reversed.