[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.4.0 ... struct with variable size array ... C90 support
- From: Francisco Olarte <folarte@...>
- Date: Fri, 15 May 2020 11:27:43 +0200
Philippe:
On Fri, May 15, 2020 at 11:01 AM Philippe Verdy <verdyp@gmail.com> wrote:
>> Have you ever worked
> Yes of course !!!
It was rhetorical.
>> with an architecture needing alignment, or
>> considered the zero length array does not need to be of a trivially
>> aligned type like char, i.e., how about { char a; int b[] }?
> Yes, not a problem, the "char a" has no alignment constraints: sizeof(a)=1 and alignof(a) =1
> But given that for example sizeof(int)=4 and alignof(int)=4 mayu be needed with some platform, b will be prepadded. with 3 bytes. The total structure has then 8 bytes, not 5
Are you sure? I would swear it is "4 not 1", and not "8 not 5":
gcc version 8.3.0 (Debian 8.3.0-6)
$ cat kk.c
#include <stdio.h>
struct { char a; int b[]; } x;
int main(int ac, char **av) {
printf("%d\n", (int)sizeof(x));
return 0;
}
$ gcc kk.c
$ ./a.out
4
Of course I had to read before replying.
> Nother is **appended**. We're just speaking about *prepending* for aligning additional fields in order to satisfy their own type constraints or performance needed to access invidual fields.
1.- I do not understand the "Nother", and giving it is capitalized I
do not know if it is a typo or out of my english knowledge and my
oxford dictionary contents.
2.- If by WE you mean you and other people but not me, may be. If by
it you mean "you and me and potentially more people", I disagree. I
was talking about you disagreeing with the link you quoted in your
original mail.
Francisco Olarte.
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org