C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Concept of Libraries in C and C++

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 03 Apr 2023 16:05:22 -0300
On Monday, 3 April 2023 11:21:51 -03 Henry Miller via Std-Proposals wrote:
> I'm not the OP, but I've long wanted a concept of shared libraries because
> on my system violated the one-definition-rule is defined behavior. There is
> set of rules for what definition takes precedence if there is more than one
> definition in the program. While it is rare I have sometimes found it
> useful to have a second definition of some symbol in my programs (ie to
> override some system call), and I want to raise this out of undefined
> behavior territory.

This is unlikely to get into the standard. (Shared) Libraries as they're
usually used with a single definition for anything has a good chance, because
they're overwhelmingly used. I'd argue that the symbol-exporting functionality
should be "export but can't override" and leave the ability to override
anything as a compiler extension. Similarly, dynamically weak symbols need to
remain extensions because they're not supported everywhere.

But poking exceptions in the One-Definition Rule is probably too niche. Not to
mention it isn't supported everywhere either (Windows, in particular).

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-04-03 19:05:26