C++ Logo

std-proposals

Advanced search

Re: [std-proposals] interlibrary Vs intralibrary

From: David Brown <david_at_[hidden]>
Date: Thu, 20 Apr 2023 16:32:39 +0200
On 20/04/2023 02:56, Thiago Macieira via Std-Proposals wrote:
> On Wednesday, 19 April 2023 17:37:23 PDT Thiago Macieira via Std-Proposals
> wrote:
>> This is impossible to implement right now because it's just not how linkers
>> work. You'd need to work with the implementations to first have a technical
>> solution, before even attempting to standardise.
>
> Let me just qualify my answer a bit.
>
> I actually think this is a good idea and could be very useful for libraries. I
> am a library developer and would definitely welcome such a solution.
>
> But it requires a lot of pre-work to be done, understanding the actual needs
> and use-cases of library developers that use static libraries, and how open
> toolchain vendors are to updating their linkers to such a feature. I do expect
> this would need a lengthy trial period as an extension in several toolchains
> before we can discuss making it standard, whether de facto or de jure. WG14 (C
> standard) needs to be involved too.
>
> I also think it needs to grow scope. If you're going to address static
> libraries, you should also address shared libraries and the sharing of
> variables and functions inside of it, versus outside. Unlike static libraries,
> this is an area where there is no need to change linkers, only standardise
> compilers.
>
> And it probably does need to address Modules.
>

C++ already has a solution to this - namespaces. A well-designed C++
library would have the global "status" variable inside a namespace.
Indeed, it is likely to be in nested namespaces - something like
"libspellcheck::internals::status". That will not conflict with any
other "status" variable in other namespaces.

And C already has a solution, albeit a bit less elegant - prefixes. A
well-designed C library would call the global "libspellcheck_status".

Received on 2023-04-20 14:32:45