martin-olivier / dylib

C++ cross-platform wrapper around dynamic loading of shared libraries (dll, so, dylib)
https://conan.io/center/recipes/dylib
MIT License
293 stars 44 forks source link

Compilation warnings with GCC on Linux #35

Closed eyalroz closed 2 years ago

eyalroz commented 2 years ago

Steps to reproduce

Configured with BUILD_TESTS and built.

Expected behaviour

No compiler warnings

Actual behaviour

/home/eyalroz/src/mine/dylib/tests/lib.cpp:4:18: warning: ‘pi_value’ initialized and declared ‘extern’
    4 | DYLIB_API double pi_value = 3.14159;
      |                  ^~~~~~~~
/home/eyalroz/src/mine/dylib/tests/lib.cpp:5:17: warning: ‘ptr’ initialized and declared ‘extern’
    5 | DYLIB_API void *ptr = (void *)1;
      |                 ^~~

Now, the warnings are pretty innocuous, but - maybe you should create an extern "C" block to avoid them? Or perhaps - a proper-C library?

martin-olivier commented 2 years ago

As I'm currently working on https://github.com/martin-olivier/dylib/issues/27 to be able to load C++ mangled symbols, the extern "C" block will be removed from DYLIB_API.

Those changes will fix unit tests GCC warnings