bug-datamash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/3] decrease visibility of local symbols


From: Georg Sauthoff
Subject: Re: [PATCH 2/3] decrease visibility of local symbols
Date: Mon, 27 Jan 2025 00:09:55 +0100

Hello,

On Sun, Jan 26, 2025 at 09:24:24PM +0000, Tim Rice wrote:
> This is another one where I think the general principle seems sound, but I'd 
> like to have more context. What's the motivation for making this change?
> 
> A web search on the topic of why bother hiding internal symbols with static 
> in C gave results that were more focused on *how* rather than *why*.

the main motiviation behind such a change basically is:

1) minimize the likelihood of possible (future) symbol clashes between
   different translation units or libraries
2) speed up linking
3) eliminate noise when using `-Wmissing-prototypes`, i.e. if your local
   symbols are 'clean', then all remaining missing-prototypes warnings
   point to missing includes or obsolete functions


Note that a global symbol definition that shadows another doesn't necessarily
yield a link error, in general.

And even in the constellations where it does, for fixing, it's way more
convenient to get a compile error, instead.


Best regards,
Georg

-- 
"No one can write decently who is distrustful of the reader's
intelligence, or whose attitude is patronizing." (William Strunk,
Jr. and E.B. White, The Elements of Style, p. 70, 1959)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]