About bitfields

Discussion in 'C Programming' started by Régis Troadec, Feb 14, 2004.

  1. Hi all,

    I follow c.l.c. for only a short time and I would like to know
    why there isn't anything concerning bitfields among the FAQs.

    Is it because ...
    1. of portability issues?
    2. bitfields aren't enough useful to be discussed?
    3. of the low frequency of questions concerning this topic?
    4. of anything else?...

    Or perhaps it would be interesting to mention bitfields among
    the FAQs with a relevant example?

    Greetings, Regis
     
    Régis Troadec, Feb 14, 2004
    #1
    1. Advertising

  2. On Sat, 14 Feb 2004, Régis Troadec wrote:

    >
    > Hi all,
    >
    > I follow c.l.c. for only a short time and I would like to know
    > why there isn't anything concerning bitfields among the FAQs.
    >
    > Is it because ...
    > 1. of portability issues?
    > 2. bitfields aren't enough useful to be discussed?
    > 3. of the low frequency of questions concerning this topic?
    > 4. of anything else?...
    >
    > Or perhaps it would be interesting to mention bitfields among
    > the FAQs with a relevant example?


    FAQ is an acronym for Frequently Asked Questions (or Frequently Answered
    Questions). If there is not a common question about bitfields being asked
    then there will be no FAQ for them.

    Having been in and out of comp.lang.c for the past 15 years and never
    remember a specific question about bitfields coming up. So I'm going to go
    with option 3 from your list.

    > Greetings, Regis
    >
    >
    >


    --
    Send e-mail to: darrell at cs dot toronto dot edu
    Don't send e-mail to
     
    Darrell Grainger, Feb 14, 2004
    #2
    1. Advertising

  3. Re'gis Troadec wrote:

    >
    > Hi all,
    >
    > I follow c.l.c. for only a short time and I would like to know
    > why there isn't anything concerning bitfields among the FAQs.
    >
    > Is it because ...
    > 1. of portability issues?
    > 2. bitfields aren't enough useful to be discussed?
    > 3. of the low frequency of questions concerning this topic?
    > 4. of anything else?...
    >
    > Or perhaps it would be interesting to mention bitfields among
    > the FAQs with a relevant example?


    The index in the book version says:

    bitfields 46-7
    and Boolean types 141
    portability of 46

    Turning to those pages, I find that questions 2.25 and 2.26 are all about
    bitfields, and 9.1 references them in a footnote.

    Checking these in the online version, I note that questions 2.25 and 2.26
    are entirely absent, and that the footnote is absent from 9.1.

    My conclusion? Bitfields are a vital aspect of modern C programming, and
    Steve Summit ruthlessly exploits this fact for hard-nosed commercial
    reasons. This also explains why he's never around comp.lang.c these days -
    he's too busy sunning himself on the yacht he bought with the royalties of
    the book version of the FAQ.

    --
    Richard Heathfield :
    "Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
    C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
    K&R answers, C books, etc: http://users.powernet.co.uk/eton
     
    Richard Heathfield, Feb 15, 2004
    #3
  4. Régis Troadec

    Dan Pop Guest

    In <> (Darrell Grainger) writes:

    >On Sat, 14 Feb 2004, R=E9gis Troadec wrote:
    >>
    >> I follow c.l.c. for only a short time and I would like to know
    >> why there isn't anything concerning bitfields among the FAQs.
    >>
    >> Is it because ...
    >> 1. of portability issues?
    >> 2. bitfields aren't enough useful to be discussed?
    >> 3. of the low frequency of questions concerning this topic?
    >> 4. of anything else?...
    >>
    >> Or perhaps it would be interesting to mention bitfields among
    >> the FAQs with a relevant example?

    >
    >FAQ is an acronym for Frequently Asked Questions (or Frequently Answered
    >Questions). If there is not a common question about bitfields being asked
    >then there will be no FAQ for them.
    >
    >Having been in and out of comp.lang.c for the past 15 years and never
    >remember a specific question about bitfields coming up. So I'm going to go
    >with option 3 from your list.


    It's not as much a matter of frequency (such questions do arise from time
    to time) as a matter of those questions not having enough in common to be
    worth an entry (or more) in the FAQ.

    Dan
    --
    Dan Pop
    DESY Zeuthen, RZ group
    Email:
     
    Dan Pop, Feb 16, 2004
    #4
  5. Régis Troadec

    CBFalconer Guest

    Richard Heathfield wrote:
    > Re'gis Troadec wrote:
    >
    > > I follow c.l.c. for only a short time and I would like to know
    > > why there isn't anything concerning bitfields among the FAQs.
    > >
    > > Is it because ...
    > > 1. of portability issues?
    > > 2. bitfields aren't enough useful to be discussed?
    > > 3. of the low frequency of questions concerning this topic?
    > > 4. of anything else?...
    > >
    > > Or perhaps it would be interesting to mention bitfields among
    > > the FAQs with a relevant example?

    >
    > The index in the book version says:
    >
    > bitfields 46-7
    > and Boolean types 141
    > portability of 46
    >
    > Turning to those pages, I find that questions 2.25 and 2.26 are
    > all about bitfields, and 9.1 references them in a footnote.
    >
    > Checking these in the online version, I note that questions 2.25
    > and 2.26 are entirely absent, and that the footnote is absent
    > from 9.1.
    >
    > My conclusion? Bitfields are a vital aspect of modern C
    > programming, and Steve Summit ruthlessly exploits this fact for
    > hard-nosed commercial reasons. This also explains why he's never
    > around comp.lang.c these days - he's too busy sunning himself on the
    > yacht he bought with the royalties of the book version of the FAQ.


    Well, you should be expert on that facet. Are you having major
    problems spending the excess royalties from "C Unleashed"?

    Note to OP: The above two (2) paragraphs could use a <sarcasm>
    indicator. In practice bitfields are not well suited to portable
    programming, due to the lack of standards about them. Masks can
    generate portable code.

    --
    Chuck F () ()
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net> USE worldnet address!
     
    CBFalconer, Feb 16, 2004
    #5
  6. CBFalconer wrote:

    > Richard Heathfield wrote:


    <snip>

    >> Bitfields are a vital aspect of modern C
    >> programming, and Steve Summit ruthlessly exploits this fact for
    >> hard-nosed commercial reasons. This also explains why he's never
    >> around comp.lang.c these days - he's too busy sunning himself on the
    >> yacht he bought with the royalties of the book version of the FAQ.

    >
    > Well, you should be expert on that facet. Are you having major
    > problems spending the excess royalties from "C Unleashed"?


    Yes, I'm afraid so. Let the reader understand.

    --
    Richard Heathfield :
    "Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
    C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
    K&R answers, C books, etc: http://users.powernet.co.uk/eton
     
    Richard Heathfield, Feb 16, 2004
    #6
  7. Régis Troadec

    Dan Pop Guest

    In <> CBFalconer <> writes:

    >Note to OP: The above two (2) paragraphs could use a <sarcasm>
    >indicator. In practice bitfields are not well suited to portable
    >programming, due to the lack of standards about them. Masks can
    >generate portable code.


    Nonsense. Bitfields are perfectly well suited to portable programming:
    let the compiler take care of the masking job.

    They are not well suited at mapping an externally imposed bit layout,
    but the need to do such a thing hardly arises in a portable programming
    context. And if it doesn't have to be done portably, it usually can be
    done, by observing how the compiler allocates the bit fields.

    Dan
    --
    Dan Pop
    DESY Zeuthen, RZ group
    Email:
     
    Dan Pop, Feb 17, 2004
    #7
  8. Régis Troadec

    CBFalconer Guest

    Dan Pop wrote:
    > CBFalconer <> writes:
    >
    > >Note to OP: The above two (2) paragraphs could use a <sarcasm>
    > >indicator. In practice bitfields are not well suited to portable
    > >programming, due to the lack of standards about them. Masks can
    > >generate portable code.

    >
    > Nonsense. Bitfields are perfectly well suited to portable programming:
    > let the compiler take care of the masking job.
    >
    > They are not well suited at mapping an externally imposed bit layout,
    > but the need to do such a thing hardly arises in a portable programming
    > context. And if it doesn't have to be done portably, it usually can be
    > done, by observing how the compiler allocates the bit fields.


    In some sense, such as packing, you are correct. However I
    conceive of bitfields as more suited to matching imposed
    constraints, such as a status word from a peripheral (which is
    what you said), and there they may well not even port between
    releases of the same compiler.

    The user has to know what he is doing in order to use them safely.

    --
    Chuck F () ()
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net> USE worldnet address!
     
    CBFalconer, Feb 17, 2004
    #8
  9. Régis Troadec

    Dan Pop Guest

    In <> CBFalconer <> writes:

    >Dan Pop wrote:
    >> CBFalconer <> writes:
    >>
    >> >Note to OP: The above two (2) paragraphs could use a <sarcasm>
    >> >indicator. In practice bitfields are not well suited to portable
    >> >programming, due to the lack of standards about them. Masks can
    >> >generate portable code.

    >>
    >> Nonsense. Bitfields are perfectly well suited to portable programming:
    >> let the compiler take care of the masking job.
    >>
    >> They are not well suited at mapping an externally imposed bit layout,
    >> but the need to do such a thing hardly arises in a portable programming
    >> context. And if it doesn't have to be done portably, it usually can be
    >> done, by observing how the compiler allocates the bit fields.

    >
    >In some sense, such as packing, you are correct. However I
    >conceive of bitfields as more suited to matching imposed
    >constraints, such as a status word from a peripheral (which is
    >what you said), and there they may well not even port between
    >releases of the same compiler.


    In theory. In practice, implementors avoid changing their compilers in
    ways that can break existing correct code. Moreover, different
    implementors usually adhere to the same set of conventions on the same
    platform.

    >The user has to know what he is doing in order to use them safely.


    This is true for each and every feature of the C language.

    Dan
    --
    Dan Pop
    DESY Zeuthen, RZ group
    Email:
     
    Dan Pop, Feb 17, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Juha Kettunen
    Replies:
    9
    Views:
    366
    Leor Zolman
    Apr 10, 2004
  2. rohit
    Replies:
    23
    Views:
    1,753
    Dave Thompson
    Jun 10, 2004
  3. Grumfish
    Replies:
    2
    Views:
    371
    Bengt Richter
    Aug 19, 2003
  4. GalenTX

    Bitfields in a heterogenous environment

    GalenTX, Feb 4, 2005, in forum: C Programming
    Replies:
    6
    Views:
    330
    GalenTX
    Feb 6, 2005
  5. Mehta Shailendrakumar

    Array of bitfields

    Mehta Shailendrakumar, Jun 17, 2005, in forum: C Programming
    Replies:
    19
    Views:
    679
    Martijn
    Jun 19, 2005
Loading...

Share This Page