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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:59:04+00:00 2026-05-27T18:59:04+00:00

I would like a standard reference why the following code triggers a compliance warning

  • 0

I would like a standard reference why the following code triggers a compliance warning in C (tested with gcc -pedantic; “typedef redefinition”), but is fine in C++ (g++ -pedantic):

typedef struct Foo Foo;
typedef struct Foo Foo;

int main() { return 0; }

Why can I not define a typedef repeatedly in C?

(This has practical implications for the header structuring of a C project.)

  • 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-27T18:59:05+00:00Added an answer on May 27, 2026 at 6:59 pm

    Why does this compile in C++?

    Because the C++ Standard explicitly says so.

    Reference:

    C++03 Standard 7.1.3 typedef specifier

    §7.1.3.2:

    In a given non-class scope, a typedef specifier can be used to redefine the name of any type declared in that scope to refer to the type to which it already refers.

    [Example:
    typedef struct s { /* … */ } s;
    typedef int I;
    typedef int I;
    typedef I I;
    —end example]

    Why does this fail to compile in C?

    typedef names have no linkage and C99 standard disallows identifiers with no linkage specification to have more than one declaration with the same scope and in the same name space.

    Reference:

    C99 Standard: §6.2.2 Linkages of identifiers

    §6.2.2/6 states:

    The following identifiers have no linkage: an identifier declared to be anything other than
    an object or a function; an identifier declared to be a function parameter;
    a block scope
    identifier for an object declared without the storage-class specifierextern.

    Further §6.7/3 states:

    If an identifier has no linkage, there shall be no more than one declaration of the identifier (in a declarator or type specifier) with the same scope and in the same name space, except for tags as specified in 6.7.2.3.

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

Sidebar

Related Questions

I would like to use standard icons in treeview but I am not sure
I would like to use standard ASP.NET file download response, like in other Stack
I would like to override the use of the standard app.config by passing a
I would like to know if in C++ standard libraries there is any gaussian
I would like to break a long line of text assigned to the standard
I would like to use a custom version of the standard disclosure accessory image
I would like to change the behaviour of the insert button on the standard
I would like to create a custom document library where I use the standard
I have a fairly standard rails app and would like to be able to
I'd like to use the following idiom, that I think is non-standard. I have

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.