Deutsch   English   Français   Italiano  
<vihpjh$2hgg1$1@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 14:50:40 +0100
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <vihpjh$2hgg1$1@dont-email.me>
References: <vi54e9$3ie0o$1@dont-email.me> <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>
 <vidnp3$1ovvm$2@paganini.bofh.team>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 01 Dec 2024 14:50:41 +0100 (CET)
Injection-Info: dont-email.me; posting-host="cb92292cff9a7aed5107a3020cf78af5";
	logging-data="2671105"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18R+2lwdsDBDhM2qR03s9kqu6ok+ZdwLco="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:cXuDkc+L/vpnw1WMAcWk0hLKJ0k=
Content-Language: en-GB
In-Reply-To: <vidnp3$1ovvm$2@paganini.bofh.team>
Bytes: 3702

On 30/11/2024 01:55, Waldek Hebisch wrote:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> Bart <bc@freeuk.com> writes:
>>> It's another point of confusion. In my language I don't treat function
>>> declarations like variable declarations. A function is not a
>>> variable. There is no data storage associated with it.
>>
>> In C, declarations can declare objects, functions, types, etc.  I fail
>> to see how your language is relevant.
>>
>>> In C it is unfortunate, as it makes it hard to trivially distinguish a
>>> function declaration (or the start of a function definition) from a
>>> variable declaration.
>>
>> It's not as hard as you insist on pretending it is.  A function
>> declaration includes a pair of parentheses, either empty or
>> containing a list of parameters or parameter types.
>>
>> Function declarations outside header files are valid, but tend to be
>> rare in well-written C code.
> 
> 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?
> 

Without doubt, most functions (and non-local data) should be static.

However, IMHO writing (non-defining) declarations for your static 
functions is a bad idea unless it is actually necessary to the code 
because you are using them in function pointers or have particularly 
good reasons for the way you order your code.

I don't find redundant declarations of static functions at all useful - 
and I find them of significant cost in maintaining files.  It is far too 
easy to forget to update them when you change, delete or add new 
functions.  And a list of such declarations that you don't feel you can 
trust entirely, is worse than useless.

Such lists might have been helpful to some people decades ago, when 
editors were more primitive.  If I need a list of functions in a file 
(maybe it's someone else's code, or old code of mine), any programmer's 
editor or IDE will give me it - updated correctly in real-time, and not 
out of sync.