0
我修改了我的項目,編譯後彈出一些奇怪的錯誤。C++ - 錯誤C3646:未知覆蓋說明符
#ifndef BART_RAY_TRACER_MESH_H
#define BART_RAY_TRACER_MESH_H
#include <vector>
#include "assert.h"
#include "vec3f.h"
class Triangle;
class Mesh {
public:
uint32_t nverts;
bool _is_static;
vec3f *verts;
vec3f *_verts_world;
Material material;
// 2 error occurs at the line below
Matrix4x4 _trans_local_to_world; // '_trans_local_to_world': unknown override specifier & missing type specifier - int assumed. Note: C++ does not support default-int
Matrix4x4 _trans_local_to_world_inv;
TransformHierarchy *_trans_hierarchy;
std::vector<Triangle* > triangles;
// ...
};
#endif
當我改變聲明的順序一點點,錯誤總是發生Material material
後線,但與不同的消息:
#ifndef BART_RAY_TRACER_MESH_H
#define BART_RAY_TRACER_MESH_H
#include <vector>
#include "assert.h"
#include "vec3f.h"
class Triangle;
class Mesh {
public:
uint32_t nverts;
bool _is_static;
vec3f *verts;
vec3f *_verts_world;
Material material;
// 2 error occurs at the line below
TransformHierarchy *_trans_hierarchy; // error C2143: syntax error: missing ';' before '*' & error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Matrix4x4 _trans_local_to_world;
Matrix4x4 _trans_local_to_world_inv;
std::vector<Triangle* > triangles;
// ...
};
#endif
我搜索過的SO,但類似的問題沒有看起來有用。 我檢查了我的vec3f
,Triangle
類的定義,以防缺少分號但我找不到任何。
任何人都可以幫忙嗎?
材料定義在哪裏? – starmole
如果你在'material'後面加上'double wtf;'這樣的原始元素,你會得到什麼結果? – user4581301
@starmole嗨!我有一個'shape.h',其中定義了三角形。 'material.h'包含在'shape.h'中。我不知道當我使用類Triangle作爲前向聲明時,是否包含'class Material'。但是我試圖在這裏包含'material.h',但仍然是同樣的問題。 –