Oh, that seems to be working now. Still got a small issue, glib compiles with -Werror=missing- prototypes:
../foo.h:7:5: error: no previous prototype for ‘g_strcmp0’ [- Werror=missing-prototypes] I'm a bit lost with what the prototype would look like in this case. I think `__attribute__((__dllexport__))` will be needed when building with MSVC at least. Seems gcc, clang and msvc each wants a different trick :/ Thanks, Xavier Claessens. Le mercredi 02 novembre 2022 à 00:06 +0800, LIU Hao a écrit : > 在 2022-11-01 23:38, xclae...@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 >