dascandy / hippomocks

GNU Lesser General Public License v2.1
192 stars 65 forks source link

Hippomock does not work properly with g++ (MinGW) on Windows #102

Closed rgrymin closed 5 years ago

rgrymin commented 5 years ago

During compilation on Windows (CLion+MinGW(g++)) we can see problem:

In file included from C:\Users\msmigielski\CLion workspace\testing_catch2\tests.cpp:14:0: C:\Users\msmigielski\CLion workspace\testing_catch2\hippomocks.h:204:46: error: expected initializer before 'VirtualProtect' extern "C" __declspec(dllimport) int WINCALL VirtualProtect(void func, unsigned long byteCount, unsigned long flags, unsigned long oldFlags); ^~~~~~ C:\Users\msmigielski\CLion workspace\testing_catch2\hippomocks.h: In constructor 'HippoMocks::Unprotect::Unprotect(void*, size_t)': C:\Users\msmigielski\CLion workspace\testing_catch2\hippomocks.h:222:73: error: 'VirtualProtect' was not declared in this scope VirtualProtect(origFunc, byteCount, PAGE_EXECUTE_READWRITE, &oldprotect); ^ C:\Users\msmigielski\CLion workspace\testing_catch2\hippomocks.h: In destructor 'HippoMocks::Unprotect::~Unprotect()': C:\Users\msmigielski\CLion workspace\testing_catch2\hippomocks.h:227:59: error: 'VirtualProtect' was not declared in this scope VirtualProtect(origFunc, byteCount, oldprotect, &dontcare); ^ mingw32-make.exe[3]: [CMakeFiles/testing_catch2.dir/tests.cpp.obj] Error 1 CMakeFiles\testing_catch2.dir\build.make:87: recipe for target 'CMakeFiles/testing_catch2.dir/tests.cpp.obj' failed CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/testing_catch2.dir/all' failed CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/testing_catch2.dir/rule' failed Makefile:117: recipe for target 'testing_catch2' failed mingw32-make.exe[2]: [CMakeFiles/testing_catch2.dir/all] Error 2 mingw32-make.exe[1]: [CMakeFiles/testing_catch2.dir/rule] Error 2 mingw32-make.exe: [testing_catch2] Error 2

y0lo commented 5 years ago

What is the windows version? Is it 64 bits?

rgrymin commented 5 years ago

yes, I already created a patch. I will provide pull request

rgrymin commented 5 years ago

suggested change is in Pull Request:

FIX: Hippomock does not work properly with g++ (MinGW) on Windows #103 https://github.com/dascandy/hippomocks/pull/103

dascandy commented 5 years ago

Pull request merged, closing. Thanks!