Search code examples
c++visual-c++c++11visual-studio-2012ctp

Syntax of strongly typed enums wrongly implemented?


I'm currently testing the November CTP for Visual Studio 2012 and came across an interesting problem: Is it mandated by the standard that for strongly typed enumerations the enum and struct/class keywords have to be in the same line or is that an error in the implementation that should be reported to Microsoft?

This compiles:

enum struct name : type { ...

This does not (C2332)

enum
struct name : type { ...

EDIT: as James suggested this is a bug in the implementation and was reported to Microsoft


Solution

  • Yes, this is undoubtedly a bug. Newlines are not significant after preprocessing.

    This is tracked by the following issue on Microsoft Connect (To the OP: Thank you for opening this bug.):

    Bug in implementation of strongly typed enums

    If this bug is important to you, please upvote it on Microsoft Connect. Note that there is a trivial workaround: don't place a newline between the enum and struct keywords.