https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61469

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org

--- Comment #8 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> (In reply to nick87720z from comment #0)
> > Unlike C++, where type is specified as "enum class type ..."
> 
> That's not how C++ does it, the correct syntax is:
> 
>   enum foo_type : int { foo, bar, baz };

clang supports this as an extension in C:

$ clang -Weverything enum.c
warning: include location '/usr/local/include' is unsafe for cross-compilation
[-Wpoison-system-directories]
enum.c:1:6: warning: enumeration types with a fixed underlying type are a Clang
extension [-Wfixed-enum-extension]
enum : int { a }; int main(void) { return 0; }
     ^~~~~
2 warnings generated.

vs. with gcc:

$ /usr/local/bin/gcc enum.c
enum.c:1:6: error: expected '{' before ':' token
    1 | enum : int { a }; int main(void) { return 0; }
      |      ^
  • [Bug c/61469] language feature... egallager at gcc dot gnu.org via Gcc-bugs

Reply via email to