error C2148: 数组的总大小不得超过0x7fffffff字节

来源:互联网 发布:数据化生产管理 编辑:程序博客网 时间:2024/06/11 02:03

1. 报错环境:

    Plane.h: class Plane{....} 有声明、有实现,但是实现部分放在Plane.cpp.

    Frustum.h:

                  class Plane;

                  class Frustum

                  {

                   ... ...

                   private:

                      Plane mPlane[6];

                  };

 

2. 错误:

          1. error C2148: 数组的总大小不得超过0x7fffffff字节。

          2. error C2079: "Frustum: mPlane" 使用未定义的 class "Plane"

 

 

3. 报错原因:

          1. 编译器需要知道每种类型的大小。但是在Frustum类中没有告诉Plane类型的大小。最终,mPlane[6]的大小就变得无限大。

 

4. 解决办法:

          1. 使用Plane *mPlane; 指针地址的大小是基于操作系统的,是固定的值。所有不会报错。

          2. 使用Plane mPlane[6].  但是在Frustum类前要包含#include "Plane.h",告知Plane类大小。