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: Small Device C Compiler 3.6.0 released Date: Sat, 18 Jun 2016 11:47:34 -0700 Organization: None to speak of Lines: 75 Message-ID: References: <874m8x2b3m.fsf@bsb.me.uk> <87y46825no.fsf@bsb.me.uk> <275e7cbe-2ac0-44ee-9669-e88911e526a0@googlegroups.com> <87inxc1zdh.fsf@bsb.me.uk> <342888eb-c388-49b8-8cd9-0466aac36157@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="25902"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/DWXjC1QSx5E23GgAe0lI7" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:eSyQzfzMGQqvTcuGJJ0AE2tm5P4= sha1:TWCg5bYPnfeVCjDScywCKmt6O7g= Xref: csiph.com comp.lang.c:89545 Keith Thompson writes: > Malcolm McLean writes: >> On Tuesday, June 14, 2016 at 4:37:30 PM UTC+1, Keith Thompson wrote: >>> Malcolm McLean writes: >>> [...] >>> > Every line of source is within the program, which is the first level of >>> > scope. >>> > Not all source is within a "translation unit" and you can play silly hacks >>> > with headers that access file scope variables. But most is. You have >>> > several source files per program. So that's nested, but only to one >>> > level. >>> [...] >>> >>> Do you have an example of source that is not within a translation unit? >>> >> /* fred.h */ >> >> sillyhack = verysilly; >> >> >> /* jim.c */ >> >> void foo() >> { >> double sillyhack; >> double verysilly = 42; >> >> #include "fred.h" >> >> printf("Silly hack was, heh heh heh %g\n", sillyhack); >> } >> >> /* bert.c */ >> >> void bar() >> { >> const char *sillyhack; >> const char *verysilly = "wabbadoo"; >> >> #include "fred.h" >> >> printf("%s\n", sillyhack); >> >> } > > Ok. > > Do you have an example of source that is not within a translation unit? > > If that was intended to be an example, what source is not within a > translation unit? > > N1570 5.1.1.1: > > A source file together with all the headers and source files > included via the preprocessing directive #include is known as a > *preprocessing translation unit*. After preprocessing, a > preprocessing translation unit is called a *translation unit*. > > When jim.c is compiled, the contents of fred.h are part of the resulting > translation unit. When bert.c is compiled, the contents of fred.h are > again part of the resulting (different) translation unit. I presume from your lack of response that you've conceded that there is no such example. Feel free to correct me (with a valid example) if that presumption is incorrect. (I suppose source code that's never compiled isn't part of any translation unit, but I don't think that's what you meant.) -- 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"