Enum names collisions

Started by
2 comments, last by simong 9 years, 4 months ago

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.

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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I've fixed this in revision 2082.

Thanks,

Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Works perfectly! Thanks Andreas.

This topic is closed to new replies.

Advertisement