无法在macOS上编译openGL教程(来自ogled)

时间:2019-09-20 18:45:48

标签: c++ opengl compiler-errors

我正在尝试从ogldev编译openGL教程40。 我在连接大量图书馆时遇到了麻烦,但是我终于做到了。 但是现在我有一个非常可疑的错误。

其中一个源代码包括来自stl的地图标头:

#include <map>

但是我的编译器告诉我:

In file included from mesh.cpp:21:
In file included from ./mesh.h:22:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/map:455:
/Library/Developer/CommandLineTools/usr/include/c++/v1/__tree:2614:14: error: 
      no matching function for call to object of type
      'std::__1::__tree<std::__1::__value_type<Edge, Neighbors>,
      std::__1::__map_value_compare<Edge, std::__1::__value_type<Edge,
      Neighbors>, CompareEdges, true>,
      std::__1::allocator<std::__1::__value_type<Edge, Neighbors> >
      >::value_compare' (aka 'std::__1::__map_value_compare<Edge,
      std::__1::__value_type<Edge, Neighbors>, CompareEdges, true>')
        if (!value_comp()(__root->__value_, __v))

稍作搜索后,我发现可能是导致此问题的比较函数,这是在mesh.h教程中声明的映射:

    map<string,uint> m_BoneMapping; // maps a bone name to its index

    std::map<Edge, Neighbors, CompareEdges> m_indexMap;
    std::map<aiVector3D, uint, CompareVectors> m_posMap;   

这是CompareEdges和CompareVectors:

struct CompareEdges
{
    bool operator()(const Edge& Edge1, const Edge& Edge2)
    {
        if (Edge1.a < Edge2.a) {
            return true;
        }
        else if (Edge1.a == Edge2.a) {
            return (Edge1.b < Edge2.b);
        }        
        else {
            return false;
        }            
    }
};


struct CompareVectors
{
    bool operator()(const aiVector3D& a, const aiVector3D& b)
    {
        if (a.x < b.x) {
            return true;
        }
        else if (a.x == b.x) {
            if (a.y < b.y) {
                return true;
            }
            else if (a.y == b.y) {
                if (a.z < b.z) {
                    return true;
                }
            }
        }

        return false;
    }
};

0 个答案:

没有答案