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
```

Updated the test case there:
https://gitlab.gnome.org/xclaesse/inline-example

Regards,
Xavier Claessens.

Le mercredi 12 octobre 2022 à 11:03 +0800, LIU Hao a écrit :
> 在 2022/10/12 02:37, xclae...@gmail.com 写道:
> > 
> > Build it with:
> >    meson setup builddir --cross-file cross_file_mingw64.txt
> >    ninja -C builddir/
> > 
> > And it fails with:
> 
> That's because you compiled it as C. I used g++ to compile these, and
> there was no such error.
> 
> 
> For C, this inline issue is going to be much more messy due to lack
> of COMDAT support about 
> `inline`. Your will need a dedicated macro for each translation unit.
> A dirty solution looks like this:
> 
>     ```
>     #ifndef INSIDE_FOO_C
>     __attribute__((__dllexport__)) inline
>     #endif
>     extern
>     int
>     g_strcmp0(const char*str1, const char*str2)
>       ...
>     ```
> 
> and in 'foo.c':
> 
>     ```
>     #define INSIDE_FOO_C  1
>     #include "foo.h"
> 
>     extern int g_strcmp0 (const char *str1, const char *str2);
>     ```
> 
> 
> Further reading:
>   
> https://github.com/lhmouse/mcfgthread/wiki/Differences-between-GNU,-C99-and-C---%60inline%60
> 
> 
> -- 
> Best regards,
> LIU Hao

Reply via email to