Samsung / rlottie

A platform independent standalone library that plays Lottie Animation.
Other
1.12k stars 219 forks source link

Windows: wrong cast of functions returnedd by GetProcAddress #171

Open vtorri opened 5 years ago

vtorri commented 5 years ago

../src/vector/vimageloader.cpp:53:79: error: cast between incompatible function types from 'FARPROC' {aka 'long long int ()()'} to 'lottie_image_load_f' {aka 'unsigned char ()(const char, int, int, int*, int)'} [-Werror=cast-function-type]

Add WINAPI in front of the function, like that :

using lottie_image_load_f = unsigned char (WINAPI )(const char filename, int x, int y, int comp, int req_comp); using lottie_image_load_data_f = unsigned char (WINAPI )(const char data, int len, int x, int y, int comp, int req_comp); using lottie_image_free_f = void (WINAPI )(unsigned char );

vtorri commented 5 years ago

this could be a g++ 8.* compiler error, i'll try with a more recent one

smohantty commented 5 years ago

@vtorri , i just used reinterpret_cast. and tried with vs2019 , i don't get that error. you can test and let me know

vtorri commented 5 years ago

yes, i'll let you know with g++ 9.*

smohantty commented 5 years ago

@vtorri , I have pushed a patch for meson build with werror and warning_level as part of default_options . so you can configure your project according to your need. ex: meson -Dwerror=false -Dwarning_level=1 builddir

vtorri commented 5 years ago

what about this solution :

https://github.com/JBamro/Makruk-Stockfish/commit/2a6d2ee8a5461113391c7776f92b30cb09898649

?

it works for me

vtorri commented 5 years ago

Note that WINAPI should be used, imho, because it sets the calling convention to what FARPROC uses : __stdcall

smohantty commented 5 years ago

@vtorri , I see .. have not much idea about windows env .. if the code works for you in your env. Could you please raise a patch for the same.

hermet commented 5 years ago

I will have a look.

vtorri commented 5 years ago

see : https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getprocaddress for FARPROC : https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-callwindowproca

usally, WINAPI is the standard calling convention : __stdcall : https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types

hermet commented 5 years ago

@vtorri if you have vs2019, this patch might be useful for you.

commit bfda7feee5dffd298c2b756219586c6c429152f8 (HEAD -> master, origin/master, origin/HEAD) Author: Hermet Park hermetpark@gmail.com Date: Fri Jul 5 18:05:43 2019 +0900

vs2019: added the preset visual studio project.

This is a compilable vs project to generate library
for the fan of visual studio.

Still, there are a lot of compile warnings,
it works to generate working dll and lib.
vtorri commented 5 years ago

as i have said, it's a gcc >= 8.* bug