Path: csiph.com!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: question about linker Date: Tue, 03 Dec 2024 11:31:12 -0800 Organization: A noiseless patient Spider Lines: 41 Message-ID: <86r06omum7.fsf@linuxsc.com> References: <877c8nt255.fsf@nosuchdomain.example.com> <20241129142810.00007920@yahoo.com> <20241129161517.000010b8@yahoo.com> <87mshhsrr0.fsf@nosuchdomain.example.com> <8734j9sj0f.fsf@nosuchdomain.example.com> <20241130190829.00007193@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Tue, 03 Dec 2024 20:31:16 +0100 (CET) Injection-Info: dont-email.me; posting-host="6df3ea726b10ab0f3de7a160d28b993d"; logging-data="308202"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199IJ10iSkRW2V0768rOGEZQ1W3s5FGKjQ=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:5EquKiTZsSqOR+VAa1xJaqWNTFE= sha1:7xa72FN/e9xsJ0s1gdNKH9stgEA= Xref: csiph.com comp.lang.c:389324 Michael S writes: > On Fri, 29 Nov 2024 20:38:51 -0500 > James Kuyper wrote: > >> On 11/29/24 19:55, Waldek Hebisch wrote: >> ... >> >>> Hmm, in well-written code static functions are likely to be a >>> majority. Some people prefer to declare all functions and >>> put declarations of static functions in the same file as the >>> functions itself. Conseqently, function declarations are not >>> rare in such code. Do you consider it well-written? >> >> I wouldn't go so far as to say that it's poorly written, but I don't >> like the unnecessary redundancy of that approach. Whenever possible, I >> prefer to let each static function's definition serve as it's only >> declaration. This isn't possible, for instance, if you have a pair of >> mutually recursive functions. >> >> The redundancy between a header file's function declaration and the >> corresponding function definition is necessary, given the way that C >> works. Avoiding that is one of the reasons I like declaring static >> functions, where appropriate. > > Top-down-minded people don't like details textually preceding "big > picture". > > [O.T.] > Better solution would be if static function definition anywhere in the > file serves like declaration (prototype) for the whole file, including > preceding part. We are long past the time where single-pass compiler > was a legit argument against such arrangement. Nowadays the only > possible counter argument would be breaking existing code. But I don't > see how such change breaks anything. You have my vote. I also vote for whole-file declarations for defined objects as well as functions, and for whole-file declarations for definitions of entities that have external linkage as well as statics.