apolukhin / Boost.DLL

Library for comfortable work with DLL and DSO
https://boost.org/libs/dll
110 stars 69 forks source link

Cast between pointer-to-function and pointer-to-object #4

Closed Kojoley closed 10 years ago

Kojoley commented 10 years ago

I got next error:

C:/Boost/include/boost-1_56/boost/plugin/detail/windows/shared_library_impl.hpp:185:86: error: invalid conversion from 'boost::detail::winapi::FARPROC_ {aka int (__attribute__((__stdcall__)) *)()}' to 'void*' [-fpermissive]
         void* const symbol = boost::detail::winapi::GetProcAddress(handle_, sb.data());

It can be fixed with using reinterpret_cast but casting between pointer-to-function void(*)() and pointer-to-object void* will cause such warning which is described on dylsym page. Since GetProcAddress could be used to get address for objects too, I can't propose a simpler way to workaround this issue than just suppress this error with using static_assert for ensuring that sizes of both pointers are equal (in shared_library.hpp).

apolukhin commented 10 years ago

As I understand you were using MinGW-4.8 with "-Wpedantic" flag.

I've committed a temporary-fix and now working on a better solution. (Line 185 in shared_library_impl.hpp is not the only place where such casts may occur.)

Kojoley commented 10 years ago

Yes I do (-Wall -Wextra -pedantic). I'm not sure if -Wpedantic enables -fpermissive (I was thinking that it just enables warnings as mentioned in GCC docs wich says Valid ISO C and ISO C++ programs should compile properly with or without this option)

Thanks for you work!