| Deutsch English Français Italiano |
|
<vihs4s$2hgg1$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!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: Sun, 1 Dec 2024 15:34:04 +0100 Organization: A noiseless patient Spider Lines: 66 Message-ID: <vihs4s$2hgg1$2@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> <vihjaj$2f79m$2@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 01 Dec 2024 15:34:05 +0100 (CET) Injection-Info: dont-email.me; posting-host="cb92292cff9a7aed5107a3020cf78af5"; logging-data="2671105"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+idGm1TTsv9nVf+4YwLJNlLBDgrqZGuIQ=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:b7cmazayxOIn1Bna7IMHsT8h5pU= In-Reply-To: <vihjaj$2f79m$2@dont-email.me> Content-Language: en-GB Bytes: 4714 On 01/12/2024 13:03, Bart wrote: > On 01/12/2024 11:34, David Brown wrote: > >> "int", "void" and "double" are totally different types in my view. >> "int", "pointer to int", "array of int", "function returning int" all >> have a relation that means I would not describe them as /totally/ >> different types - though I would obviously still call them /different/ >> types. >> > > What about 'array of int', 'array of double' and 'array of void*'; do > they have a relation too? > In a different context, yes - they can all be used in expressions of the form "a[i]". Different context, different relationship. > Your examples, expressed left-to-right, happen to share the last > element. They could also share other elements; so what? > All I was saying is that it is wrong to say a single declaration can have identifiers of /totally/ different types - the types you are allowed to use in one declaration have a very clear relationship with each other. >>> Function declarations outside header files are valid, but tend to be >>> rare in well-written C code. >>> >> >> A function definition - as typically written - is also a function >> declaration. So presumably you mean non-defining declaration here. >> >> 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. > > That's a separate problem. But without forward declarations, at some > point you're going to add some expression in the middle of the file, but > find you're calling a function which is declared later on in the file > rather than earlier. > > That's not something you want to waste time thinking about. It's not something I find to be a noticeable issue. I prefer, on the whole, to avoid forward declarations - I like to order by code so that functions are defined before they are called. It makes it easier to see the structure of the code and call trees. There are exceptions when I feel a different order is clearest, but those are rare and I can put up with writing static function declarations in those cases. (For non-static functions, there is invariably a declaration in a matching header file.) I can see some advantages in a language being happy with any order of function definition, without requiring forward declarations to use a function before it is defined. But C is not like that, and I cannot honestly say it bothers me one way or the other. And apparently, it does not particularly bother many people - there is, I think, no serious impediment or backwards compatibility issue that would prevent C being changed in this way. Yet no one has felt the need for it - at least not strongly enough to fight for it going in the standard or being a common compiler extension.