0

When I add a module(using OpenGL and glm) (which tested and compiled OK as a single program) into a big program. errors happened when compiling the glm in the project:

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. 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.

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)

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

#undef  INTERFACE
#define INTERFACE   IBanneredBar
// the rest of the shlobj.h file
Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
toolchainX
  • 1,998
  • 3
  • 27
  • 43
  • Could you provide the code where the problem appears? Maybe forgotten semicolon, or something duplicated in the process of splitting up into separate files? – codeling Oct 22 '12 at 12:22
  • @RandolphCarter I add the code the error indicator pointing at – toolchainX Oct 22 '12 at 13:02
  • 1
    shouldn't it be `template class TYPE` (you're missing the template parameter name) – codeling Oct 22 '12 at 13:05
  • 1
    and BMICON_LARGE sounds like a predefined constant from windows; if you absolutely need to redeclare an enum value with that name, put it into a separate namespace – codeling Oct 22 '12 at 13:06
  • problem solved. in the big program, someone using the `#define short TYPE` which conflict with the `TYPE` in the `type_gentype.hpp` – toolchainX Oct 22 '12 at 13:56

1 Answers1

1

Regarding BMICON_LARGE, this sounds like there is already a predefined constant / enum value by that name. 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.

codeling
  • 11,056
  • 4
  • 42
  • 71