Issue with dllexport/dllimport inline function

LIU Hao lh_mouse@126.com
Tue Nov 1 16:06:32 GMT 2022


在 2022-11-01 23:38, xclaesse@gmail.com 写道:
> Thanks a lot for your help.
> 
> Sorry for late reply, but I gave your trick a try and it did not work:
> ```
> /home/xclaesse/programmation/inline-example/builddir/../foo.h:7:
> multiple definition of `g_strcmp0';
> libfoo.dll.p/foo.c.obj:/home/xclaesse/programmation/inline-
> example/builddir/../foo.h:7: first defined here
> ```
> 

Apologies for the typo. The `__dllexport__` in 'foo.h' should have been `__gnu_inline__`. If, for 
some reason, it needs to be specified explicitly, you may do that in 'foo.c' instead.

'foo.h':
    ```
    #ifndef INSIDE_FOO_C
    __attribute__((__gnu_inline__)) __inline__
    #endif
    extern
    int g_strcmp0(const char*str1, const char*str2) {
      ...
    ```

'foo.c':
    ```
    __attribute__((__dllexport__)) /* This is optional.  */
    extern int g_strcmp0 (const char *str1, const char *str2);
    ```




-- 
Best regards,
LIU Hao

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20221102/b4289487/attachment.sig>


More information about the Gcc mailing list