C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Ensure ABI compatibility at runtime -- std::layout_of

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Fri, 8 Nov 2024 11:56:43 +0000
On Thu, Nov 7, 2024 at 6:22 PM Thiago Macieira wrote:
>
> On Thursday 7 November 2024 07:29:38 Pacific Standard Time Jeremy Rifkin via
> Std-Proposals wrote:
> > My suggestion: Rrquire plugins to publish a C string with some identifier
> > indicating the standard library being used (e.g. "libstdc++" or "libcxx"
> > depending on preprocessor macros set by the libraries). Then check that on
> > load.
>
> Prior to the load.
>
> That means you need to require your OS to provide a way to get that string for
> a potential plugin before it is loaded.


I haven't coded the following yet, but it's what I'm planning to do.
So the plugin will be in the form of:

    Windows : DLL file
    Linux : SO file
    Apple : DYNLIB file

I will build the plugin as a shared library file, and then I'll append
a known UUID to the file contents, something like

    echo "8749cd5638ddd35726a524567dc9e63e" >> libplugin.so

After the UUID, I'll append any info I need, such as strings and
translations, version numbers, etc.

And so then prior to using "dlopen" or "LoadLibrary", I'll use an
'ifstream' to open the file, I'll seek to the end of the file, then
I'll go backwards til I find the UUID, and then I'll load the data
after the UUID. This is how I'll get some info about the file before
loading it (i.e. before executing it's '_init' code). I might check a
checksum also to see if the file's corrupt.

Received on 2024-11-08 11:56:56