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

The Archive Base Latest Questions

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

According to me, it is zero but there seems to be bit confusion here

  • 0

According to me, it is zero but there seems to be bit confusion here

I have tested it with gcc compiler and it gives me zero as output. I know that in C++, size of an empty class is 1. Let me know if I am missing anything here.

  • 1 1 Answer
  • 2 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-12T18:27:18+00:00Added an answer on May 12, 2026 at 6:27 pm

    A struct cannot be empty in C because the syntax forbids it. Furthermore, there is a semantic constraint that makes behavior undefined if a struct has no named member:

    struct-or-union-specifier:
      struct-or-union identifieropt { struct-declaration-list }
      struct-or-union identifier
    
    struct-or-union:
      struct
      union
    
    struct-declaration-list:
      struct-declaration
      struct-declaration-list struct-declaration
    
    struct-declaration:
      specifier-qualifier-list struct-declarator-list ;
    
    /* type-specifier or qualifier required here! */
    specifier-qualifier-list:
      type-specifier specifier-qualifier-listopt
      type-qualifier specifier-qualifier-listopt
    
    struct-declarator-list:
      struct-declarator
      struct-declarator-list , struct-declarator
    
    struct-declarator:
      declarator
      declaratoropt : constant-expression
    

    If you write

    struct identifier { };
    

    It will give you a diagnostic message, because you violate syntactic rules. If you write

    struct identifier { int : 0; };
    

    Then you have a non-empty struct with no named members, thus making behavior undefined, and not requiring a diagnostic:

    If the struct-declaration-list contains no named members, the behavior is undefined.

    Notice that the following is disallowed because a flexible array member cannot be the first member:

    struct identifier { type ident[]; };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to documentation , On success, zero is returned but none of the functions
I have been using blocks for some time now, but I feel that there
according to me following while loop should be infinite but it runs only thrice
Let's say I have a schema in which an apple crate contains zero or
Here is my situation, I have a div which has height:400px and overflow:auto to
This might be a trivial question, but I have not found anything about it,
according to this , directionRenderer object's method setRouteIndex() should Set the (zero-based) index of
I have a question about joins when using Linq to Entities. According to the
Now according to all the literature echo 1234abcd|sed s|[0-9]\+|#|g should output #abcd. And echo
I'm not sure how to explain the behavior I'm seeing, but here goes. I

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.