C++编译出现 类型未声明
ringa_lee
ringa_lee 2017-04-17 15:35:09
0
2
620

C++ 头文件中已经用#include 包含了类型声明的头文件,为什么还会提示该类型没有声明(error: 'cfdemCloudIB' has not been declared)?已经排除了类之间互相包含的可能性;还有其他可能情况吗?

ringa_lee
ringa_lee

ringa_lee

reply all(2)
伊谢尔伦
  1. Are you compiling under linux or window?

  2. 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

#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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template