Empty structures

This is a discussion on Empty structures within the C Programming forums, part of the General Programming Boards category; Hi, What is the purpose of using empty structures in C? I know this is only a gcc extension. Thanks,...

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    2

    Empty structures

    Hi,

    What is the purpose of using empty structures in C? I know this is only a gcc extension.

    Thanks,

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,851
    Read the gcc extension to discover why they think it's a good idea (perhaps)?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    May 2007
    Posts
    2
    Not much info regarding this extension. http://developer.apple.com/documenta...pty-Structures

    I would like to know why someone would use an empty structure, you cannot assign anything...

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,851
    It may on occasion allow
    Code:
    struct foo {
    #ifdef SOMETHING
        int  a;
    #endif
    #ifdef SOMETHING_ELSE
        int  b;
    #endif
    };
    If both conditions were false, then the structure would be empty.
    Without the extension, you might struggle to declare a minimally 'empty' struct containing only one char to make the compiler shut up.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with binary file c++
    By lucky_mutani in forum C++ Programming
    Replies: 4
    Last Post: 06-05-2009, 10:24 AM
  2. Replies: 2
    Last Post: 07-11-2008, 08:39 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. Classes and Structures.
    By jrahhali in forum C++ Programming
    Replies: 6
    Last Post: 03-28-2004, 05:03 PM
  5. Methods for Sorting Structures by Element...
    By Sebastiani in forum C Programming
    Replies: 9
    Last Post: 09-14-2001, 01:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21