Deutsch English Français Italiano |
<vik2ub$390ho$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!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: David Brown <david.brown@hesbynett.no> Newsgroups: comp.lang.c Subject: Re: question about linker Date: Mon, 2 Dec 2024 11:42:19 +0100 Organization: A noiseless patient Spider Lines: 44 Message-ID: <vik2ub$390ho$1@dont-email.me> References: <vi54e9$3ie0o$1@dont-email.me> <vi6sb1$148h7$1@paganini.bofh.team> <vi6uaj$3ve13$2@dont-email.me> <87plmfu2ub.fsf@nosuchdomain.example.com> <vi9jk4$gse4$1@dont-email.me> <vi9kng$gn4c$1@dont-email.me> <87frnbt9jn.fsf@nosuchdomain.example.com> <viaqh0$nm7q$1@dont-email.me> <877c8nt255.fsf@nosuchdomain.example.com> <viasv4$nm7q$2@dont-email.me> <vibr1l$vvjf$1@dont-email.me> <vic73f$1205f$1@dont-email.me> <20241129142810.00007920@yahoo.com> <vicfra$13nl4$1@dont-email.me> <20241129161517.000010b8@yahoo.com> <vicque$15ium$2@dont-email.me> <vid110$16hte$1@dont-email.me> <87mshhsrr0.fsf@nosuchdomain.example.com> <vidd2a$18k9j$1@dont-email.me> <8734j9sj0f.fsf@nosuchdomain.example.com> <vihhkj$2er60$1@dont-email.me> <87bjxvqcv2.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 02 Dec 2024 11:42:20 +0100 (CET) Injection-Info: dont-email.me; posting-host="aa0a75e8a34576a95bb9121ab8c66e54"; logging-data="3441208"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/P2naCd18cHqvGBBG213nzzgKluS7ehm8=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cancel-Lock: sha1:mvIB6cLB6HAar1DDIEWFsfL8q/8= Content-Language: en-GB In-Reply-To: <87bjxvqcv2.fsf@nosuchdomain.example.com> Bytes: 3951 On 01/12/2024 23:04, Keith Thompson wrote: > David Brown <david.brown@hesbynett.no> writes: >> On 30/11/2024 00:44, Keith Thompson wrote: (I hope that the issue of "totally different types" is now cleared up and can be laid to rest.) > >> A function definition - as typically written - is also a function >> declaration. So presumably you mean non-defining declaration here. > > Yes. > >> Some people have a style where they write forward declarations of all >> functions defined in a C file near the top of the file. I am not a >> fan of that myself - especially as over time, this redundant >> information is rarely kept fully in sync with the rest of the code. >> But it is definitely something you'll sometimes see in real-world C >> code. (You could argue that the code is then not "well-written" C, >> but that would be a very subjective opinion.) > > Yes, that was an oversight on my part. > > If someone wanted to ensure that all static functions defined in a > translation unit are declared near the top, there could be a separate > tool to generate, or at least check, the declarations. I'm not aware of > any such tool, which suggests there probably isn't much demand for it. > It is also possible that people who want such tools would simply write them themselves. I suspect that for most people, writing a script that would do this job for their own code would be quick and simple, while writing one that worked fully for all possible cases would be much more of an effort. For example, in my own code I know that all static functions are defined with "static" at the start of the line, and I know that I never have static data definitions that include parentheses unless it is part of an initialiser (and therefore after the equals sign). This would make writing such a script for my own use very simple. But a general tool could not use such shortcuts - someone could use function pointer types in a static variable declaration, and of course it would have to pre-process the code before extracting the declarations.