Jump to content
  • Advertisement
Sign in to follow this  
Red Ant

Fully qualified names (.NET 2003 C++)

This topic is 4725 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, I have a namespace:
namespace ServerClientConventions
{
    enum Recurrence
    {
        NEVER = 0,
        ONCE = 1,
        CONTINUOUSLY = -1
    };

    // Loads of other stuff ...
};

When, from outside that namespace, I say for example
ServerClientConventions::Recurrence bla = ServerClientConventions::Recurrence::NEVER;

The compiler spits out an error: u:\g120tools\dtools\ASTS_versioned\Server\h\ATSServer.h(87) : error C2039: 'NEVER' : is not a member of 'ServerClientConventions::Recurrence' u:\g120tools\dtools\ASTS_versioned\ServerClientConventions\h\ServerClientConventions.h(47) : see declaration of 'ServerClientConventions::Recurrence' u:\g120tools\dtools\ASTS_versioned\Server\h\ATSServer.h(87) : error C2065: 'NEVER' : undeclared identifier When it CLEARLY is a member. Strangely, if I ommit the name of the enum, like so:
ServerClientConventions::Recurrence bla = ServerClientConventions::NEVER;

it works!! WHY?? Am I not allowed to use the fully qualified name of the enum's element??

Share this post


Link to post
Share on other sites
Advertisement
No you are not. C++ enum names go directly to the hosting namespace (or global namespace). In C# it is different, so this can cause some confusion.

Share this post


Link to post
Share on other sites
Grent is right.

The Sun and GCC compilers actually give you a more meaningful error message.

Sun - ServerClientConventions::Recurrence is not a namespace or class
GCC - ServerClientConventions::Recurrence is not an aggregate type

Both of those are a little more helpful than the VC++ message.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!