xcode遇到的2个小问题 Conflicting types、vtable for

112 阅读1分钟

Conflicting types的报错

mac上xcode其实给出的错误信息比较多,而且非常有用,大概报错如下:

Conflicting types for 'glDepthRange':
In file included from xxx.cpp
In file included from xxx.cpp
In file included from xxx.cpp
Expanded from macro 'glDepthRangef'
revious declaration is here

我是因为OpenGL的头文件必须在glew.h前声明,所以对头文件的引入顺序有要求

一定要仔细的排查In file included from,排查这个代码里面的include,确保include嵌套也不会出问题,确保里面的顺序。

vtable for xxx

: "vtable for TouchLayer", referenced from:
: A missing vtable usually means the first non-inline virtual member function has no definition.

大概意思就是有虚函数没有实现,但是我仔细检查了代码,不存在这个问题,因为我使用的是cmake,所以排查后发现,cpp文件没有加入到工程里面,加入到里面就正常通过编译了。