Deutsch English Français Italiano |
<v6jhvb$1drd6$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: David Brown <david.brown@hesbynett.no> Newsgroups: comp.lang.c Subject: =?UTF-8?Q?Re=3a_technology_discussion_=e2=86=92_does_the_world_need?= =?UTF-8?B?IGEgIm5ldyIgQyA/?= Date: Tue, 9 Jul 2024 16:37:31 +0200 Organization: A noiseless patient Spider Lines: 51 Message-ID: <v6jhvb$1drd6$2@dont-email.me> References: <v66eci$2qeee$1@dont-email.me> <v67gt1$2vq6a$2@dont-email.me> <v687h2$36i6p$1@dont-email.me> <871q48w98e.fsf@nosuchdomain.example.com> <v68dsm$37sg2$1@dont-email.me> <87wmlzvfqp.fsf@nosuchdomain.example.com> <v6ard1$3ngh6$4@dont-email.me> <v6b0jv$3nnt6$1@dont-email.me> <v6c298$3tko2$1@dont-email.me> <v6c688$3uf4o$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Tue, 09 Jul 2024 16:37:32 +0200 (CEST) Injection-Info: dont-email.me; posting-host="b5f81ffa340fccea092912f722a4136c"; logging-data="1502630"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/UX/+S7vUJPK+dkOscRsueMTsQKXbrbTI=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cancel-Lock: sha1:ejozjkpw+azCMg0CMZh6F5BKvHQ= Content-Language: en-GB In-Reply-To: <v6c688$3uf4o$1@dont-email.me> Bytes: 2999 On 06/07/2024 21:33, BGB wrote: > > In my compiler (BGBCC), such an internal pointer exists for arrays and > structures in the local stack frame. > > No separate pointer exists inside of things like structs, where, as can > be noted, the array exists at a fixed size and location. > > > So, eg: > void Foo() > { > int a[100]; > ... > } > > There is both the space for 100 integers reserved in the stack frame, > and a variable 'a' which exists as an implicit pointer to that location. > > > But, say: > void Foo() > { > int a[8192]; > ... > } > > There is no space reserved on the stack, and the array is instead > allocated dynamically (from the heap). In this case, the "a" variable > exists as a pointer to that location in memory. > > Similar treatment also applies to structs. > The C standard does not require a stack or say how local data is implemented, it just gives rules for the scope and lifetime of locals. However, I would be surprised and shocked to find a compiler I was using allocate local data on the heap in some manner. If I have an array as local data, it is with the expectation that it is allocated and freed trivially (an add or subtract to the stack pointer, typically combined with any other stack frame). If I want something on the heap, I will use malloc and put it on the heap. Such an implementation as yours is not, I think, against the C standards - but IMHO it is very much against C philosophy.