static inline and jextract
Manuel Bleichenbacher
manuel.bleichenbacher at gmail.com
Tue Sep 6 12:57:08 UTC 2022
There are two indications that it's definition and not a declaration:
- absence of "extern" keyword
- presence of initialization ( = { 0x... )
If it was compiled as C/C++ code, it would allocate memory in the current
compilation unit while a declaration would just refer to something outside
the compilation unit.
Definitions are rare in header files as they usually lead to duplicate
symbol errors at link time. But through the magic of __declspec(selectany),
this is avoided.
On Tue, Sep 6, 2022 at 12:11 PM Maurizio Cimadamore <
maurizio.cimadamore at oracle.com> wrote:
>
> On 05/09/2022 16:32, Manuel Bleichenbacher wrote:
> > extern "C" const GUID __declspec(selectany) GUID_DEVINTERFACE_USB_DEVICE
> > = { 0xA5DCBF10L, 0x6530, 0x11D2, { 0x90, 0x1F, 0x00, 0xC0,
> > 0x4F, 0xB9, 0x51, 0xED } };
> >
> I guess the problem here is the lack of "dllexport", right?
>
> But, while dllexport is common, some libraries can still export symbols
> using a .def file [1].
>
> So, I'm not sure this belongs in the same category as "static inline",
> as it is not possible, just by looking at the header, to understand
> whether the symbol will be present or not?
>
> [1] -
>
> https://docs.microsoft.com/en-us/cpp/build/exporting-from-a-dll-using-def-files?view=msvc-170
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jextract-dev/attachments/20220906/e9ea51e1/attachment.htm>
More information about the jextract-dev
mailing list