C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Proposal: Deprecate namespace-scope declarations that are declared both static and inline

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 22 Jun 2026 11:34:30 -0400
On Monday, 22 June 2026 08:21:42 Eastern Daylight Time Yexuan Xiao via Std-
Proposals wrote:
> Since C does not have namespaces, these libraries use internal linkage to
> avoid symbol conflicts.

No, that's not why they do it.

They do it because the implementation of non-static inline functions in C are,
IMNSHO, a mis-feature.

When the compiler decides not to inline it, it emits a call to an out-of-line
function that the developer of the library must have provided. I have never
seen the explanation of how to just export from one .c file the inline
implementation for all other TUs (by that I mean I haven't bothered to go
looking for it).

For a non-inlined static inline function, the compiler must emit an out-of-
line copy because another TU cannot provide an internal-linkage symbol for
this TU.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-06-22 15:34:34