简体   繁体   English

OpenGL重定义错误,同时编译与Windows SDK文件的glm冲突

[英]OpenGL redefinition error while compiling glm conflict with Windows SDK files

When I add a module(using OpenGL and glm ) (which tested and compiled OK as a single program) into a big program. 当我添加一个模块(使用OpenGLglm )(将OK作为单个程序测试并编译)到一个大程序中时。 errors happened when compiling the glm in the project: 在项目中编译glm时发生错误:

1>d:\program files (x86)\microsoft visual studio 9.0\vc\include\glm\core\type_gentype.hpp(48) : error C2332: “class”: missing tag name
1>d:\program files (x86)\microsoft visual studio 9.0\vc\include\glm\core\type_gentype.hpp(48) : error C2011: “<unnamed-tag>”: “enum” type redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\shlobj.h(3599) : see declaration of '<unnamed-tag>'

I searched google and found a similar problem at here . 我搜索了google,并在这里发现了类似的问题。 the answer said it has something wrong with the header file sequence, but I don't know how to fix it. 答案说头文件序列有问题,但是我不知道如何解决。

the code in the type_gentype.hpp , the code is in the glm . 该代码在type_gentype.hpp ,该代码在glm中

namespace glm
{
    enum profile
    {
        nice,
        fast,
        simd
    };

namespace detail
{
    template
    <
        typename VALTYPE, 
        template <typename> class TYPE   //**The error indicator pointing at here**
    >
    struct genType
    {
    public:
        enum ctor{null};

        typedef VALTYPE value_type;
        typedef VALTYPE & value_reference;
        typedef VALTYPE * value_pointer;
        typedef VALTYPE const * value_const_pointer;
        typedef TYPE<bool> bool_type;

        typedef sizeType size_type;
        static bool is_vector();
        static bool is_matrix();

        typedef TYPE<VALTYPE> type;
        typedef TYPE<VALTYPE> * pointer;
        typedef TYPE<VALTYPE> const * const_pointer;
        typedef TYPE<VALTYPE> const * const const_pointer_const;
        typedef TYPE<VALTYPE> * const pointer_const;
        typedef TYPE<VALTYPE> & reference;
        typedef TYPE<VALTYPE> const & const_reference;
        typedef TYPE<VALTYPE> const & param_type;

        //////////////////////////////////////
        // Address (Implementation details)

        value_const_pointer value_address() const{return value_pointer(this);}
        value_pointer value_address(){return value_pointer(this);}

    //protected:
    //  enum kind
    //  {
    //      GEN_TYPE,
    //      VEC_TYPE,
    //      MAT_TYPE
    //  };

    //  typedef typename TYPE::kind kind;
    };

    template
    <
        typename VALTYPE, 
        template <typename> class TYPE
    >
    bool genType<VALTYPE, TYPE>::is_vector()
    {
        return true;
    }

The redefinition part of the enum in the c:\\program files\\microsoft sdks\\windows\\v6.0a\\include\\shlobj.h(3599) c:\\program files\\microsoft sdks\\windows\\v6.0a\\include\\shlobj.h(3599) enum的重定义部分c:\\program files\\microsoft sdks\\windows\\v6.0a\\include\\shlobj.h(3599)

enum
{   // **The error indicator pointing at here**
    BMICON_LARGE = 0,
    BMICON_SMALL
};

#undef  INTERFACE
#define INTERFACE   IBanneredBar
// the rest of the shlobj.h file

Regarding BMICON_LARGE, this sounds like there is already a predefined constant / enum value by that name. 关于BMICON_LARGE,这听起来好像已经有了该名称的预定义常量/枚举值。 The best solution would be to simply use a different name. 最好的解决方案是简单地使用其他名称。 If you absolutely need to have that exact name, put it into your own namespace; 如果您绝对需要该名称,则将其放入您自己的名称空间; or you could maybe use the already defined value. 或者您可以使用已经定义的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM