Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: double strtod( const char *nPtr, char **endPrt); Date: Thu, 12 Nov 2015 17:14:55 -0800 Organization: None to speak of Lines: 41 Message-ID: References: <6b8eee47-6184-45f2-8b56-b0e51c16a763@googlegroups.com> <8bbcc376-a820-4308-b8f2-90bcf4fa13e2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="4331"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+jzp9ErzVBDrNaRrMUwhHh" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:akreM2LjBJxDIMbe0k043eu419c= sha1:24PSgmaMIchsFv2llrV5qTYouUM= Xref: csiph.com comp.lang.c:75907 supercat@casperkitty.com writes: > On Thursday, November 12, 2015 at 2:48:23 PM UTC-6, Keith Thompson wrote: >> A compiler doesn't create an object. It generates code that results in >> the creation of an object when that code is executed. > > I've seen a number of compilers where a file containing: > > char *getmsg(int n) { return n ? "Yep" : "Nope"; } > > will get turned into something closer to: > > static unsinged char __static_data[9] = > {'Y','e','p',0, 'N','o','p','e', 0}; > char *getmsg(int n) { return n ? __static_data+0, > __static_data+4; } > > So from the point of view of the linker there is for each compilation > unit only one blob holding all the static data from that unit, rather > than a separate blob for each string literal. Only from the point of > view of the compiler is "Nope\0" a distinct object. From the point of view of the C language, the anonymous array containing "Nope\0" is a distinct object. Distinct objects can easily be adjacent in memory. But the object does not exist until after you execute the program. > Otherwise, my main point was that saying object is created "at > runtime" would in most contexts imply that it was created at the point > where the string literal was used in the code. That is true of some > BASIC interpreters, but is not true of typical C implementations. But that's not what I said. The array object has static storage duration, so it's allocated during program startup (before main is entered) and remains allocated until the program terminates. That's still run time. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"