c++ - error C3646: unknown override specifier
Solution 1
This is just another Microsoft cock-up. Here it is in essence:
class C
{
x y ;
} ;
If you submit this to a sensible compiler like g++, it gives you a helpful error message:
3:2: error: 'x' does not name a type
MSVC, on the other hand, comes up with this gibberish:
(3): error C3646: 'y': unknown override specifier
(3): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
With this key, you can decrypt Microsoft's error message into:
error: 'Matrix4x4' does not name a type
Solution 2
The error is most likely because that TransformHierarchy
and Matrix4x4
are not defined.
If they are not defined in "assert.h"
and "vec3f.h"
, this should be the case.
Forward declaration is enough only when you use the reference types and/or pointer types only. Therefore, to forward declare Triangle
is OK. But forward declare Triangle
does not mean your shape.h
is processed. Neither does your material.h
which is included in shape.h
.
Therefore, all names in material.h
is not visible from this code.
TransformHierarchy
and Matrix4x4
are not recognized by the compiler.
Many of the compliers will complain with words similar to "missing type specifier - int assumed"
Solution 3
In my case, it was found that a header file had the following directives for a class [ie, myComboBoxData]
#ifndef __COMBOBOXDATA__
#define __COMBOBOXDATA__
// ...
class myComboBoxData
{
// ...
}
#endif
As another class below tried to use myComboBoxData
class
class TypeDlg : public CDialog
{
myComboBoxData cbRow,cbCol;
// ...
}
the error message popped up as above:
"error C3646: 'cbRow': unknown override specifier".
Solution:
The problem was the directive name (__COMBOBOXDATA__
) was already used by OTHER header.
Thus, make sure to use some other name like (__myCOMBOBOXDATA__
).
Related videos on Youtube
Comments
-
jinglei about 1 year
I modified my project and after compiling there pop up some weird error.
#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
When I change the order of the declaration a little bit, the error always occurs the line after
Material material
, but with different message:#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
I've searched for similar questions on SO but none seems useful. I've checked my
vec3f
,Triangle
class definition in case there are missing semicolons but I can't find any.Can any one help?
-
starmole about 6 yearsWhere is Material defined?
-
cdhowie about 6 yearsBased on the errors, it sounds like neither
Matrix4x4
norTransformHierarchy
are declared yet. You may be missing includes for both.
-