Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6805677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:36:58+00:00 2026-05-26T19:36:58+00:00

Code: #ifdef _MSC_VER # pragma warning( disable: 4480 ) // enum base as nonstandard

  • 0

Code:

#ifdef _MSC_VER
#    pragma warning( disable: 4480 )     // enum base as "nonstandard extension"
#endif
enum ShouldBeFine: char { hola };

enum Choice { a, b, c };

template< Choice c > struct Traits;

template<> struct Traits<a> { typedef char Type; };
template<> struct Traits<b> { typedef wchar_t Type; };
template<> struct Traits<c> { typedef long Type; };

template< Choice c >
struct Blah
{
    enum X: typename Traits<c>::Type {};
};

int main()
{} 

Only after a Herculean effort to file a bug report with Microsoft, did it occur to me that maybe Visual C++ is correct to refuse it, and g++, which compiles the above fine, is maybe wrong?

EDIT Details: the code fails to compile with Visual C++ 10.0 and with the preview of Visual C++ 11.0. Those compilers spit out some rambling error avalanche beginning with an alleged syntax error. The code compiles fine with MinGW g++ 4.4.1. Dani reports that it compiles fine with CLang. Unfortunately Comeau Online does not support this language feature, so it can’t be decided in the way we often did for C++98, just give the code to Comeau.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:36:58+00:00Added an answer on May 26, 2026 at 7:36 pm

    If I am reading the grammar correctly, you are correct in that this should compile. enum-base is : type-specifier-seq, and type-specifier-seq seems to include pretty much any type name you can think of, including typename Traits<c>::Type. And all three specializations result in Type being integral, which is also required of the enum-base. So That looks kosher to me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code : #define LIMIT_DATE \01-03-2010\ #ifdef LIMIT_DATE #if _MSC_VER #pragma
Can someone please explain what #ifdef..#else..#endif does in this piece of code? It's from
I added this in my code: #ifdef DEBUG_MODE printf(i=%d\n,i); fflush(stdout); #endif and my question
#ifdef __cplusplus // C++ code #else // C code #endif The structure is this.
Given the following C++ code, #ifdef __cplusplus extern C { #endif struct foo {
So I can do something like #ifdef MSVC //do compiler specific code here #endif
I have the following code snippet: #ifdef DO_LOG #define log(p) record(p) #else #define log(p)
In my code, I want to conditionally perform a few operations with: #ifdef DEBUG
So I can write code like this: #ifdef [whatever] // do stuff that will
Here is my code: #ifdef DEBUG UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@ERROR message:@JSON Parsing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.