Sujet : Re: So You Think You Can Const?
De : jameskuyper (at) *nospam* alumni.caltech.edu (James Kuyper)
Groupes : comp.lang.cDate : 08. Jan 2025, 20:20:00
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vlmj50$2tu5l$1@dont-email.me>
References : 1 2 3 4 5 6
User-Agent : Mozilla Thunderbird
On 1/8/25 14:10, James Kuyper wrote:
...
Objects with automatic storage duration are never defined, so they
cannot be defined to be 'const'.
That was supposed to be "allocated", not "automatic".
Objects with automatic storage duration can be defined as const:
void func(void) {
const int the_answer = 42;
}
On some implementations, they may even be stored in read-only memory.