hasherezade / libpeconv

A library to load, manipulate, dump PE files. See also: https://github.com/hasherezade/libpeconv_tpl
https://hasherezade.github.io/libpeconv
BSD 2-Clause "Simplified" License
1.09k stars 177 forks source link

Compiler error when building with MinGW #20

Closed hillu closed 4 years ago

hillu commented 4 years ago

I am trying to cross-build libpeconv (and eventually pe-sieve) on a Debian/buster system using x86_64-w64-mingw32-g++ (GCC) 8.3-win32 20190406 and am getting the following error:

$WORK/libpeconv/src/imports_loader.cpp: In instantiation of ‘bool FillImportThunks::processThunks_tpl(LPSTR, T_IMAGE_THUNK_DATA*, T_FIELD*, T_FIELD) [with T_FIELD = long unsigned int; T_IMAGE_THUNK_DATA = _IMAGE_THUNK_DATA32; LPSTR = char*; CHAR = char]’:
$WORK/libpeconv/src/imports_loader.cpp:24:107:   required from here
$WORK/libpeconv/src/imports_loader.cpp:60:23: error: cast from ‘FARPROC’ {aka ‘long long int (*)()’} to ‘long unsigned int’ loses precision [-fpermissive]
         (*call_via) = reinterpret_cast<T_FIELD>(hProc);
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Adding -fpermissive to CXXFLAGS as hinted by the compiler makes the problem go away.

hasherezade commented 4 years ago

I already had some checks not allowing the imports to be loaded via loader of mismatching bitness. But now I implemented them via ifdefs, so that the template will never be applied in such cases. Please let me know if it helps.

hillu commented 4 years ago

Yes, this particular error is gone.