Thread: bit fields before non-bit fields . . .

  1. #1
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057

    bit fields before non-bit fields . . .

    Is it true that all bit fields must be before any non-bit field members of a structure?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Anybody? It was in Sams Teach Yourself C in 21 Days, so I don't know if it's true or not.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Quote Originally Posted by dwks
    Is it true that all bit fields must be before any non-bit field members of a structure?
    No, it's not.

    Quote Originally Posted by dwks
    Anybody? It was in Sams Teach Yourself C in 21 Days, so I don't know if it's true or not.
    I've heard from various people that reading that book does more harm than good.
    Last edited by cwr; 10-12-2005 at 07:47 PM.

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    DON'T BUMP YOUR THREADS!

    Heaven forbid it takes someone more then 20 minutes to respond.

  5. #5
    ---
    Join Date
    May 2004
    Posts
    1,379
    I think I read somewhere that it was true.

  6. #6
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Quote Originally Posted by sand_man
    I think I read somewhere that it was true.
    Perhaps the same place dwks did, it's not.

  7. #7
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Perhaps it's a one of the reasons to avoid the Teach Yourself X in Y Days/Hours/Minutues books.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  8. #8
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Quote Originally Posted by Dave_Sinkula
    Perhaps it's a one of the reasons to avoid the Teach Yourself X in Y Days/Hours/Minutues books.
    Browsing through the book via that link, it seems to be riddled with errors.

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    I am stunned by the number of errors in that link
    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.

  10. #10
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    I made the mistake of purchasing Sams Teach Yourself C++ in 24 hours. It sort of squishes each topic up, leaving 3 - 6 pages for each topic so I didn't find there was enough info. It took me the best part of 18 months to get a basic grasp on the language as a whole and of course I'm still learning to this day (nearly 3 years later).

    Has anyone got The C++ Programming Language (Stroustrup)? I was considering buying it - is it "any good"?

    *edit*

    Just realised this is the C Programming board... oh well.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  11. #11
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Quote Originally Posted by ahluka
    Has anyone got The C++ Programming Language (Stroustrup)? I was considering buying it - is it "any good"?
    http://www.parashift.com/c++-faq-lit...learn-cpp.html

    Just realised this is the C Programming board... oh well.
    Indeed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. bit fields and union
    By azerej in forum C Programming
    Replies: 4
    Last Post: 05-26-2008, 06:33 PM
  2. union in struct with bit fields
    By sagarnewase in forum C Programming
    Replies: 4
    Last Post: 05-12-2008, 07:30 AM
  3. bit patterns of negtive numbers?
    By chunlee in forum C Programming
    Replies: 4
    Last Post: 11-08-2004, 08:20 AM
  4. Bit fields
    By GaPe in forum C Programming
    Replies: 8
    Last Post: 01-22-2002, 02:01 PM
  5. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-25-2001, 11:45 PM