Jump to content
  • Advertisement
Sign in to follow this  
simong

Enum names collisions

This topic is 1381 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

 

I'm having some issue trying to register two enums that have the same name. One is in the global namespace and the other lives inside a class. I thought that I could register the second one by using a namespace but apparently I still got some name collision errors.

 

I just stumbled upon this thread and though this was fixed a long time ago, but I think the issue I'm having might still be related because I still have errors when one of the two enums is living in the global namespace. Here's an example.

 

The c++ enums I'd like to register:

 

enum {
    VALUE_A,
    VALUE_B
} Enum;
 
namespace enum_ns {
    enum {
        VALUE_A,
        VALUE_B
    } Enum;
}
 
And here's the code I'm trying to use to register the two enums.
 
engine->RegisterEnum( "Enum" );
engine->RegisterEnumValue( "Enum", "VALUE_A", Enum::VALUE_A );
engine->RegisterEnumValue( "Enum", "VALUE_B", Enum::VALUE_B );
 
engine->SetDefaultNamespace( "enum_ns" );
engine->RegisterEnum( "Enum" );
engine->RegisterEnumValue( "Enum", "VALUE_A", enum_ns::Enum::VALUE_A );
engine->RegisterEnumValue( "Enum", "VALUE_B", enum_ns::Enum::VALUE_B );
engine->SetDefaultNamespace( "" );
 
If I try to execute this I have this error message; And as Code:-13 suggests things that have already been registered I guess the scope of the Enum can't be solved correcly.
 

 (0, 0) : ERR  : Failed in call to function 'RegisterEnum' with 'Enum' (Code: -1)

 (0, 0) : ERR  : Failed in call to function 'RegisterEnumValue' with 'Enum' and 'VALUE_A' (Code: -13)

 (0, 0) : ERR  : Failed in call to function 'RegisterEnumValue' with 'Enum' and 'VALUE_B' (Code: -13)

 (0, 0) : ERR  : Invalid configuration. Verify the registered application interface.

 

The funny thing is that if I do it the other way around and register the non-global one first, I don't have any error message. Unfortunately in the application I'm working on I can't really predict in what order this is going to be registered, so I'm afraid this doesn't really help!

 

I'm not sure if I can think of an other alternative. Has someone already experienced this before? Am I doing something wrong?

 

Thanks a lot for any suggestions.

 

Simon.

Edited by Simon Geilfus

Share this post


Link to post
Share on other sites
Advertisement

That's odd. I'll investigate this and have it fixed. 

 

In the meantime, the obvious work-around is to register the enum with a different name. :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!