Skip to content

Enums within namespaces: Clang warning, C++11 feature #4

Description

@IngwiePhoenix

Whilst building, I encountered a warning several times - here is a snippet:

> ./ext/./minihttp/minihttp.cpp:37:44: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
>             {OS_TEXT("SSLR_OK"), minihttp::SSLResult::SSLR_OK},
>                                            ^

I was confused at first, but when I put the warning into google, I ended up here: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20150112/121520.html
If you scroll down, you can see a testcase, which demonstrates this:

+namespace PR16951 {
+  namespace ns {
+    enum an_enumeration {
+      ENUMERATOR  // expected-note{{'ENUMERATOR' declared here}}
+    };
+  }
+
+  int x1 = ns::an_enumeration::ENUMERATOR; // expected-warning{{use of enumeration in a nested name specifier is a C++11 extension}}

So as it turns out, putting an enum into a namespace is C++11 and upwards. I myself was...well, surprised wouldn't suit it. But I would have assumed that naturally, anything can go into a namespace - turns out this is wrong.

So I'd like to ask for these enums to be moved upwards and renamed. It's just two anyway:

  • minihttp::SSLResult -> minihttp_SSLResult
  • minihttp::HttpCode -> minihttp_HttpCode

I am just suggesting these, but they would make the most sense, and allow non-C++11 compilers to not become confused :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions