Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: gcc and 'include' Date: Mon, 30 Mar 2026 05:33:06 -0700 Organization: A noiseless patient Spider Lines: 42 Message-ID: <86mrzp1oql.fsf@linuxsc.com> References: <10q4ceb$38i2d$1@dont-email.me> <87ikaiw5g0.fsf@example.invalid> <10q5nnr$3l3lc$1@dont-email.me> <10q6snp$2nka$5@dont-email.me> <10q6uv4$419b$1@dont-email.me> <20260328203718.00005c70@yahoo.com> <10q96uf$rjbn$1@dont-email.me> <10q9t6d$2p36t$1@paganini.bofh.team> <10qc632$1uds9$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Mon, 30 Mar 2026 12:33:09 +0000 (UTC) Injection-Info: dont-email.me; posting-host="2cd52f7e7f6c86e7548f05bf3bc2e07a"; logging-data="2539403"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18HbMZKZ8gCmgAbZOAIiKe6foW6p0r39ho=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:PXqihQnhTHaTKTaawOLdlTUNlgI= sha1:F4RiaEABjKTqrg5jPT7T7qv1aJs= Xref: csiph.com comp.lang.c:397303 Bart writes: > On 29/03/2026 00:53, Waldek Hebisch wrote: > >> Bart wrote: >> >>> That you declare 'abc' as something to be imported, yet in the next line >>> it is initialised as though it was exported. >> >> Well, C is not able to directy express notion of export and import. >> Also, C does not have modules/interfaces etc. Instead C object >> may be global (which is specified by 'extern' or by lack of storage >> class at file scope) or local. C rules allow you to emulate >> modules using header files. Namely, in header file you put >> 'extern' declaration for exports of given module. Any user of >> of the module must include the corresponding header file. >> To ensure consistency also implementation of the module should >> include the header file. So everywhere elso you have just >> 'extern' declaration, but in implementation there is 'extern' >> declaration first followed by the definition. If such >> sequence was disallowed, then it would be harder to check >> consistency of implementation and corresponding header. >> >> So in reasonable code 'extern' really means "part of interface" >> without specifying if it is import or export. > > But, the rules are lax, and implementations exploit that by all > behaving a little differently. The rules are not lax; they are carefully and precisely defined. To see that one needs to know what the rules are, which in turn depends on reading and understanding the C standard. > TBF, the diverse implementations probably came first, and the > standard had to accommodate existing practice. Diverse implementations certainly came first, including especially the original description of C in "The C Programming Language", by Kernighan and Ritchie. The rules for global symbols in K&R C are markedly different than those in the current C standard. There is a long explanation of different options considered for standard C, given in the C Rationale document.