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

  • Home
  • SEARCH
  • 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 7406579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:34:47+00:00 2026-05-29T05:34:47+00:00

Anonymous structs have been added in the C11 standard, so typedef struct { struct

  • 0

Anonymous structs have been added in the C11 standard, so

typedef struct { 
    struct {int a, b};
    int c; 
} abc_struct;

is valid and standard. Is it also within the standard to use a typedef in place of the full struct declaration? E.g.:

typedef struct { 
    int a, b;
} ab_struct;

typedef struct { 
    ab_struct;
    int c; 
} abc_struct;

The GCC documentation says that this is a Plan 9 extension, but then it works in the
few compilers I’ve tried (including GCC…). By my reading of the standard itself,
I think it’s OK, but this is the sort of close reading that’s easy to screw up.

  • 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-29T05:34:48+00:00Added an answer on May 29, 2026 at 5:34 am

    This was apparently asked in a question to the C committee by Joseph S. Myers of the gcc team. And the answer is no, it is not valid in C11.

    See the answer here:

    http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1549.pdf

    And Myers’s comment:

    This week’s London WG14 meeting agreed to disallow the use of typedefs in declaring anonymous structure and union fields, as per N1549.

    source http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01151.html

    The question was asked in SC22WG15.12205 see 5.28 SC22WG14.12205, Anonymous Structures (N1425) in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1490.pdf

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

Sidebar

Related Questions

I have a struct: typedef struct _n { int type; union { char *s;
I have been using anonymous namespaces to store local data and functions and wanted
C11 adds, among other things, 'Anonymous Structs and Unions'. I poked around but could
In C++, I have a class which contains an anonymous bitfield struct. I want
I have an anonymous struct in my code that I'd like to access via
C11 supports anonymous structures, like so: struct Foo { struct { size_t x, y;
Here is an (artificial) example of using a function that returns an anonymous struct
Anonymous functions are available from PHP 5.3 . Should I use them or avoid
I have an anonymous inner class inside another class ( SomeClass ). Both SomeClass.class.getClasses()
If I have an anonymous type created by LINQ var ans = from r

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.