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


Groups > comp.lang.c > #167779

Re: variable addresses on the stack

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c
Subject Re: variable addresses on the stack
Date 2022-09-21 15:30 -0700
Organization None to speak of
Message-ID <878rmcfjik.fsf@nosuchdomain.example.com> (permalink)
References <54f99ed2-fe4d-4cab-944c-cb61799d64ecn@googlegroups.com> <871qtc868m.fsf@nosuchdomain.example.com> <f2dfb3b5-379f-42d8-9bdc-99051a56d7e0n@googlegroups.com> <50c4530a-b411-4ceb-8b8c-2181a15afd8fn@googlegroups.com>

Show all headers | View raw


Thiago Adams <thiago.adams@gmail.com> writes:
[...]
> C99 added Flexible array members
>
> struct s {
>     int n;
>     double d[]; 
> };
>
> Does anyone have suggestion how to write this in C89?
>
> struct s {
>     int n;
>     double d[1]; //maybe?
> };
>
> The sizeof a struct with flexible array members is not not clear.. 

The (questionably legal) predecessor to flexible array members was
known as the "struct hack".  See question 2.6 of the comp.lang.c FAQ.

https://www.c-faq.com/

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

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


Thread

variable addresses on the stack Thiago Adams <thiago.adams@gmail.com> - 2022-08-19 10:22 -0700
  Re: variable addresses on the stack Thiago Adams <thiago.adams@gmail.com> - 2022-08-19 10:27 -0700
  Re: variable addresses on the stack Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-08-19 10:59 -0700
    Re: variable addresses on the stack Thiago Adams <thiago.adams@gmail.com> - 2022-09-21 05:09 -0700
      Re: variable addresses on the stack Thiago Adams <thiago.adams@gmail.com> - 2022-09-21 05:18 -0700
        Re: variable addresses on the stack Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-09-21 15:30 -0700
      Re: variable addresses on the stack David Brown <david.brown@hesbynett.no> - 2022-09-21 15:34 +0200
      Re: variable addresses on the stack Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-09-21 15:23 -0700
  Re: variable addresses on the stack Kaz Kylheku <480-992-1380@kylheku.com> - 2022-08-19 20:58 +0000
  Re: variable addresses on the stack Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2022-08-19 15:47 -0600
  Re: variable addresses on the stack Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-08-19 18:47 -0700

csiph-web