Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #5369

Re: offsetof() Macro Attempt

From Billy Mays <noway@nohow.com>
Newsgroups comp.lang.c
Subject Re: offsetof() Macro Attempt
Date 2011-06-03 13:59 -0400
Organization Aioe.org NNTP Server
Message-ID <isb7f4$80h$3@speranza.aioe.org> (permalink)
References <isb79p$oao$1@dont-email.me>

Show all headers | View raw


 > ...
> #define DUMMY_OF(type) ((type *)*helper)
> #define ADDRESS_AT(address) ((char *)(address))
> #define DUMMY_MEMBER_ADDRESS(type, member) (&DUMMY_OF(type)->member)
> #define PROTECT(expression) (sizeof (char[(expression)]))
> #define OFFSETOF(type, member) (PROTECT( \
> ADDRESS_AT(DUMMY_MEMBER_ADDRESS(type, member)) - \
> ADDRESS_AT(DUMMY_OF(type)) \
> ))
>
> struct s {
> int x;
> short y;
> int z;
> };
>
> enum foo {
> bar = OFFSETOF(struct s, z)
> };
>
> int main(void) {
> return 0;
> }
>
> Are there any null pointers or other dragons in there?
>
> Thanks for any insight you can provide!


As far as I can tell, it deterministically returns 0 every time.

--
Bill

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

offsetof() Macro Attempt Shao Miller <sha0.miller@gmail.com> - 2011-06-03 13:57 -0400
  Re: offsetof() Macro Attempt Billy Mays <noway@nohow.com> - 2011-06-03 13:59 -0400
    Re: offsetof() Macro Attempt Shao Miller <sha0.miller@gmail.com> - 2011-06-03 14:33 -0400
      Re: offsetof() Macro Attempt Noob <root@127.0.0.1> - 2011-06-08 15:03 +0200
  Re: offsetof() Macro Attempt pete <pfiland@mindspring.com> - 2011-06-03 14:48 -0400
    Re: offsetof() Macro Attempt Shao Miller <sha0.miller@gmail.com> - 2011-06-04 02:02 -0500
      Re: offsetof() Macro Attempt pete <pfiland@mindspring.com> - 2011-06-04 06:49 -0400
        Re: offsetof() Macro Attempt Shao Miller <sha0.miller@gmail.com> - 2011-06-04 09:32 -0500
          Re: offsetof() Macro Attempt pete <pfiland@mindspring.com> - 2011-06-04 12:55 -0400
            Re: offsetof() Macro Attempt Shao Miller <sha0.miller@gmail.com> - 2011-06-04 13:24 -0500
              Re: offsetof() Macro Attempt pete <pfiland@mindspring.com> - 2011-06-04 14:56 -0400
                Re: offsetof() Macro Attempt pete <pfiland@mindspring.com> - 2011-06-04 15:38 -0400
                Re: offsetof() Macro Attempt Shao Miller <sha0.miller@gmail.com> - 2011-06-04 18:25 -0500
                Re: offsetof() Macro Attempt pete <pfiland@mindspring.com> - 2011-06-05 07:10 -0400
  Re: offsetof() Macro Attempt Harald van Dijk <truedfx@gmail.com> - 2011-06-03 13:39 -0700
    Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-03 19:58 -0700
      Re: offsetof() Macro Attempt Harald van Dijk <truedfx@gmail.com> - 2011-06-04 01:57 -0700
        Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-04 05:22 -0700
          Re: offsetof() Macro Attempt Harald van Dijk <truedfx@gmail.com> - 2011-06-04 10:16 -0700
            Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-04 23:03 -0700
              Re: offsetof() Macro Attempt Harald van Dijk <truedfx@gmail.com> - 2011-06-05 02:24 -0700
                Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-06 08:08 -0700
                Re: offsetof() Macro Attempt Harald van Dijk <truedfx@gmail.com> - 2011-06-06 13:26 -0700
                Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-08 12:34 -0700
                Re: offsetof() Macro Attempt Harald van Dijk <truedfx@gmail.com> - 2011-06-08 15:07 -0700
                Re: offsetof() Macro Attempt Harald van Dijk <truedfx@gmail.com> - 2011-06-08 15:19 -0700
                Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-14 14:53 -0700
                Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-14 14:52 -0700
                Re: offsetof() Macro Attempt Harald van Dijk <truedfx@gmail.com> - 2011-06-14 16:24 -0700
                Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-15 06:44 -0700
                Re: offsetof() Macro Attempt Harald van Dijk <truedfx@gmail.com> - 2011-06-15 10:40 -0700
                Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-19 13:48 -0700
                Re: offsetof() Macro Attempt Harald van Dijk <truedfx@gmail.com> - 2011-06-19 14:57 -0700
                Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-23 00:52 -0700
                Re: offsetof() Macro Attempt Harald van Dijk <truedfx@gmail.com> - 2011-06-23 12:34 -0700
                Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-27 10:03 -0700
                Re: offsetof() Macro Attempt Harald van Dijk <truedfx@gmail.com> - 2011-07-01 10:03 -0700
                Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-03 14:33 -0700
                Re: offsetof() Macro Attempt Michael Press <rubrum@pacbell.net> - 2011-06-18 21:17 -0700
                Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-27 10:13 -0700
    Re: offsetof() Macro Attempt Shao Miller <sha0.miller@gmail.com> - 2011-06-04 14:05 -0500
      Re: offsetof() Macro Attempt Harald van Dijk <truedfx@gmail.com> - 2011-06-05 02:44 -0700
        Re: offsetof() Macro Attempt Shao Miller <sha0.miller@gmail.com> - 2011-06-06 17:58 -0500
          Re: offsetof() Macro Attempt Harald van Dijk <truedfx@gmail.com> - 2011-06-06 15:37 -0700
            Re: offsetof() Macro Attempt Shao Miller <sha0.miller@gmail.com> - 2011-06-06 18:58 -0500
  Re: offsetof() Macro Attempt Andrey Tarasevich <andreytarasevich@hotmail.com> - 2011-06-03 17:15 -0700
    Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-03 20:20 -0700
    Re: offsetof() Macro Attempt Shao Miller <sha0.miller@gmail.com> - 2011-06-04 12:50 -0500
  Re: offsetof() Macro Attempt Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-03 21:43 -0400
    Re: offsetof() Macro Attempt Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-03 21:54 -0400
      Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-03 20:36 -0700
  Re: offsetof() Macro Attempt Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-03 19:46 -0700

csiph-web