search

Home  >  Q&A  >  body text

C++编译出现 类型未声明

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

ringa_leeringa_lee2814 days ago637

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-17 15:37:09

    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.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 15:37:09

    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.

    reply
    0
  • Cancelreply