2012-10-22 36 views
0

當我添加一個模塊(使用OpenGLglm)(測試和編譯好作爲一個單一的程序)到一個大的程序。OpenGL重定義錯誤,同時編譯與Windows SDK文件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>' 

我搜索谷歌和here發現了類似的問題:在項目編制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; 
    } 

enumc:\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 
+0

你能提供問題出現的代碼嗎?也許是忘記了分號,或者是在分裂成單獨文件的過程中重複的東西? – codeling

+0

@RandolphCarter我添加了代碼錯誤指示器指向 – toolchainX

+1

不應該是'template class TYPE'(你缺少模板參數名稱) – codeling

回答

1

重新界定部分關於BMICON_LARGE,這聽起來像已經存在具有該名稱的預定義的常量/枚舉值。最好的解決方案是簡單地使用不同的名稱。如果你確實需要這個確切的名字,把它放到你自己的名字空間中;或者你也可以使用已定義的值。