#27 offsetof macro on Linux 2.6.9 needs to be __builtin_offsetof

David Gay
ncc (18)
Chad Metcalf

This is discussed on the TinyOS Help list:


I'm running Ubuntu with kernel 2.6.12-10-386 and gcc
3.3, 3.4, and 4.0.2. I changed c-parse.gperf as
indicated and $TOSROOT/tools/java/net/tinyos/sim
finally built correctly for me. I tested TOSSIM with
simple apps (Blink, CntToLedAndRfm, etc) and it seems
to work fine.

I've attached a patch for 1.2.4. I know you aren't
going to want to include the patch because it will
break on Windows, apparently non 2.6.9 kernels of
Linux, and others.

But I wasn't sure how you would want to setup the
conditional in c-parse.gperf. Or even if you'd want to
fix it at all as opposed to mentioning a patch. If you
do want to do it I'd be willing to do the work if you
want to tell me what method you want used.

I'd just like to get the patch more visable. Google is
great but making the answers easy to find is great too. :)


  • Chad Metcalf
    Chad Metcalf

    offsetof to __builtin_offsetof patch

  • David Gay
    David Gay

    • status: open --> closed-fixed
  • David Gay
    David Gay

    Logged In: YES

    I incorporated this in the current CVS, it will show up in
    1.2.5 (well, actually, it now accepts both offsetof and

    At some future date, it might be necessary to change
    make_offsetof (in expr.c), as it rewrites offsetof to the
    usual macro expansion...