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 9085039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:08:55+00:00 2026-06-16T21:08:55+00:00

Possible Duplicate: Is the typedef-name optional in a typedef declaration? I’m on Visual Studio

  • 0

Possible Duplicate:
Is the typedef-name optional in a typedef declaration?

I’m on Visual Studio 2008 and I saw this:

typedef enum testfoo
{
    enum1,
    enum2,
    enum3
};

Normally the C-style way of using typedef this way requires one additional piece (the name):

typedef enum testfoo
{
    enum1,
    enum2,
    enum3
} testfoo_name;

What is the former example doing? Strangely it compiles, but not sure what it’s actually defining.

  • 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-06-16T21:08:56+00:00Added an answer on June 16, 2026 at 9:08 pm

    There is a difference. The second creates an alias for the enum but the first doesn’t. The typedef in the first example doesn’t actually do anything. This gives me a warning in GCC so I suspect you can take it out.

    In C, it’s common to typedef structs and enums so as to avoid instantiating with the struct or enum name. For instance:

    struct A {};
    
    struct A a;
    

    To shorten this, a typedef does the trick:

    typedef struct {} A;
    

    This is no longer necessary in C++ so I’m deriving my assumption of his misconception with this concept. Or maybe the author forgot to give it a name…

    The same thing occurs when using classes or structs:

    typedef struct A {}; // simply a class-declaration, generates a warning
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Typedef pointers a good idea? I've seen this oddity in many APIs
Possible Duplicate: Difference between ‘struct’ and ‘typedef struct’ in C++? An answer to this
Possible Duplicate: Convert objective-c typedef to its string equivalent I have an enum declared
Possible Duplicate: Bitfield manipulation in C I saw some c codes, typedef a struct,
Possible Duplicate: What are the differences between typedef and using in C++11? The following
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Circular definition in C typedef struct{ node *next; node *last; } doubleLink;
Possible Duplicate: What does ‘unsigned temp:3’ means I just found this code in a
Possible Duplicate: Circular Dependency with forward declaration error I have two files, one that

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.