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


Groups > comp.lang.c > #7834

Re: Alignment of foo[1][1][1][1]

From Shao Miller <sha0.miller@gmail.com>
Newsgroups comp.lang.c
Subject Re: Alignment of foo[1][1][1][1]
Date 2011-07-07 09:31 -0400
Organization A noiseless patient Spider
Message-ID <iv4cc5$bas$1@dont-email.me> (permalink)
References <iugt1r$b5q$1@dont-email.me> <iv27au$9bu$1@dont-email.me> <4ef96460-ec9c-4959-909d-9d633579a8cd@j15g2000yqf.googlegroups.com> <iv2e2k$lad$1@dont-email.me> <iv2l3n$ffp$1@oravannahka.helsinki.fi>

Show all headers | View raw


On 7/6/2011 17:46, Lauri Alanko wrote:
> In article<iv2e2k$lad$1@dont-email.me>,
> Shao Miller<sha0.miller@gmail.com>  wrote:
>> On 7/6/2011 14:34, Harald van Dijk wrote:
>>> But the more common solution of a struct that you yourself mention:
>>>
>>>     typedef struct { int data; } foo;
>>>     typedef struct { int data; } bar;
>>>
>>> works just as well.
>>>
>>
>> 'foo' and 'bar' needn't be the same size as 'int'.  Their post gave me
>> the impression that they already had interface functions for pointers to
>> the "inner type," so I sensed that it was "too late" for the strategy
>> you show above.  So I'm assuming that there is already a library and the
>> request is towards adding a newer piece.
>
> No, the design of the library hasn't been fixed yet.
>

D'oh!  Of course "discussion partner" == Lauri Alanko.  You always have 
interesting things to discuss. :)  Sorry about forgetting.  I have to 
start using the favourite attribute in this news-reader.

> The problem with the above solution is not that it requires choosing a
> particular representation, but that it requires _exposing_ that
> representation in a public header. I'd like to avoid that as far as
> possible, and that's why I like pointers to incomplete structs or,
> failing that, struct wrappers for void pointers.

Ah, so the array obfuscation doesn't work either, then.  You don't want 
your API users to be able to use 'sizeof' on the base type, period.

Regardless of that, the array alignment business of this thread is still 
a bit odd.

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


Thread

Alignment of foo[1][1][1][1] Shao Miller <sha0.miller@gmail.com> - 2011-06-29 23:11 -0500
  Re: Alignment of foo[1][1][1][1] Shao Miller <sha0.miller@gmail.com> - 2011-06-29 23:13 -0500
  Re: Alignment of foo[1][1][1][1] Harald van Dijk <truedfx@gmail.com> - 2011-07-01 09:57 -0700
  Re: Alignment of foo[1][1][1][1] lawrence.jones@siemens.com - 2011-07-02 14:56 -0400
    Re: Alignment of foo[1][1][1][1] Harald van Dijk <truedfx@gmail.com> - 2011-07-02 14:16 -0700
      Re: Alignment of foo[1][1][1][1] Shao Miller <sha0.miller@gmail.com> - 2011-07-06 10:07 -0400
        Re: Alignment of foo[1][1][1][1] Harald van Dijk <truedfx@gmail.com> - 2011-07-06 08:55 -0700
          Re: Alignment of foo[1][1][1][1] Shao Miller <sha0.miller@gmail.com> - 2011-07-06 13:53 -0400
            Re: Alignment of foo[1][1][1][1] Harald van Dijk <truedfx@gmail.com> - 2011-07-06 11:34 -0700
              Re: Alignment of foo[1][1][1][1] Shao Miller <sha0.miller@gmail.com> - 2011-07-06 15:48 -0400
                Re: Alignment of foo[1][1][1][1] Lauri Alanko <la@iki.fi> - 2011-07-06 21:46 +0000
                Re: Alignment of foo[1][1][1][1] Shao Miller <sha0.miller@gmail.com> - 2011-07-07 09:31 -0400
                Re: Alignment of foo[1][1][1][1] Harald van Dijk <truedfx@gmail.com> - 2011-07-06 14:50 -0700
                Re: Alignment of foo[1][1][1][1] Shao Miller <sha0.miller@gmail.com> - 2011-07-07 09:43 -0400
    Re: Alignment of foo[1][1][1][1] Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-03 15:57 -0700
      Re: Alignment of foo[1][1][1][1] lawrence.jones@siemens.com - 2011-07-06 00:06 -0400
        Re: Alignment of foo[1][1][1][1] Shao Miller <sha0.miller@gmail.com> - 2011-07-06 13:25 -0400
        Re: Alignment of foo[1][1][1][1] Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-07 00:21 -0700
          Re: Alignment of foo[1][1][1][1] Shao Miller <sha0.miller@gmail.com> - 2011-07-07 23:24 -0400
            Re: Alignment of foo[1][1][1][1] Harald van Dijk <truedfx@gmail.com> - 2011-07-08 09:11 -0700
              Re: Alignment of foo[1][1][1][1] Seebs <usenet-nospam@seebs.net> - 2011-07-08 17:21 +0000
                Re: Alignment of foo[1][1][1][1] Harald van Dijk <truedfx@gmail.com> - 2011-07-08 11:55 -0700
                Re: Alignment of foo[1][1][1][1] Seebs <usenet-nospam@seebs.net> - 2011-07-08 23:02 +0000
                Re: Alignment of foo[1][1][1][1] Harald van Dijk <truedfx@gmail.com> - 2011-07-08 16:41 -0700
                Re: Alignment of foo[1][1][1][1] Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-09 10:32 -0700
                Re: Alignment of foo[1][1][1][1] Harald van Dijk <truedfx@gmail.com> - 2011-07-09 13:22 -0700
                Re: Alignment of foo[1][1][1][1] Tim Rentsch <txr@alumni.caltech.edu> - 2011-09-04 12:23 -0700
                Re: Alignment of foo[1][1][1][1] Harald van Dijk <truedfx@gmail.com> - 2011-09-04 13:29 -0700
                Re: Alignment of foo[1][1][1][1] Keith Thompson <kst-u@mib.org> - 2011-09-04 15:40 -0700
                Re: Alignment of foo[1][1][1][1] Harald van Dijk <truedfx@gmail.com> - 2011-09-04 22:15 -0700
                Re: Alignment of foo[1][1][1][1] Keith Thompson <kst-u@mib.org> - 2011-09-05 00:12 -0700
                Re: Alignment of foo[1][1][1][1] James Kuyper <jameskuyper@verizon.net> - 2011-09-04 18:45 -0400
                Re: Alignment of foo[1][1][1][1] Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-09 10:00 -0700
              Re: Alignment of foo[1][1][1][1] Shao Miller <sha0.miller@gmail.com> - 2011-07-08 23:55 -0400
              Re: Alignment of foo[1][1][1][1] Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-09 08:55 -0700
                Re: Alignment of foo[1][1][1][1] Harald van Dijk <truedfx@gmail.com> - 2011-07-09 09:19 -0700
                Re: Alignment of foo[1][1][1][1] Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-09 10:48 -0700
                Re: Alignment of foo[1][1][1][1] Harald van Dijk <truedfx@gmail.com> - 2011-07-09 13:25 -0700
                Re: Alignment of foo[1][1][1][1] Tim Rentsch <txr@alumni.caltech.edu> - 2011-09-04 11:00 -0700
                Re: Alignment of foo[1][1][1][1] Keith Thompson <kst-u@mib.org> - 2011-09-04 13:34 -0700
                Re: Alignment of foo[1][1][1][1] Harald van Dijk <truedfx@gmail.com> - 2011-09-04 13:06 -0700
  Re: Alignment of foo[1][1][1][1] Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-03 15:23 -0700

csiph-web