Sign in to follow this  

Enum names collisions

This topic is 1100 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

This topic is 1100 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this