Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build for Windows with raw MSC #45

Merged
merged 1 commit into from
Jun 4, 2023
Merged

Conversation

navytux
Copy link
Contributor

@navytux navytux commented May 22, 2023

Plain MSC defines _WIN32 but not WIN32 and this leads to build errors like this:

Z:\home\kirr\src\tools\go\pygo-win\BuildTools\vc\tools\msvc\14.35.32215\bin\Hostx64\x64\cl.exe /c /nologo /O2 /W3 /GL /DNDEBUG /
MD -DFUNCHOOK_EXPORTS -I. -I.\golang\_compat\windows -I3rdparty/funchook/include -I3rdparty/funchook/distorm/include -Ibuild\tem
p.win-amd64-cpython-310\Release\. -Ibuild\temp.win-amd64-cpython-310\. -Ibuild\lib.win-amd64-cpython-310\. -Ibuild\. -Iz:\home\k
irr\src\tools\go\pygo-win\BuildTools\vc\tools\msvc\14.35.32215\include -Iz:\home\kirr\src\tools\go\pygo-win\BuildTools\kits\10\i
nclude\10.0.22000.0\shared -Iz:\home\kirr\src\tools\go\pygo-win\BuildTools\kits\10\include\10.0.22000.0\ucrt -Iz:\home\kirr\src\
tools\go\pygo-win\BuildTools\kits\10\include\10.0.22000.0\um -Iz:\home\kirr\src\tools\go\pygo-win\BuildTools\kits\10\include\10.
0.22000.0\winrt /Tc3rdparty/funchook/src/funchook.c /Fobuild\temp.win-amd64-cpython-310\Release\3rdparty/funchook/src/funchook.obj
funchook.c
3rdparty/funchook/src/funchook.c(61): error C2065: 'PATH_MAX': undeclared identifier
3rdparty/funchook/src/funchook.c(61): error C2057: expected constant expression
3rdparty/funchook/src/funchook.c(61): error C2466: cannot allocate an array of constant size 0
3rdparty/funchook/src/funchook.c(84): fatal error C1189: #error:  unsupported OS or compiler
error: command 'Z:\\home\\kirr\\src\\tools\\go\\pygo-win\\BuildTools\\vc\\tools\\msvc\\14.35.32215\\bin\\Hostx64\\x64\\cl.exe' f
ailed with exit code 2

https://stackoverflow.com/a/74084728/9456786
https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170

also CMake on recent VisualStudio is reported not to define WIN32 as well

https://developercommunity.visualstudio.com/t/win32-not-defined/722576

-> Fix this by using _WIN32 instead of WIN32 in the sources everywhere.

P.S. Thanks a lot for funchook!

Plain MSC defines _WIN32 but not WIN32 and this leads to build errors
like this:

    Z:\home\kirr\src\tools\go\pygo-win\BuildTools\vc\tools\msvc\14.35.32215\bin\Hostx64\x64\cl.exe /c /nologo /O2 /W3 /GL /DNDEBUG /
    MD -DFUNCHOOK_EXPORTS -I. -I.\golang\_compat\windows -I3rdparty/funchook/include -I3rdparty/funchook/distorm/include -Ibuild\tem
    p.win-amd64-cpython-310\Release\. -Ibuild\temp.win-amd64-cpython-310\. -Ibuild\lib.win-amd64-cpython-310\. -Ibuild\. -Iz:\home\k
    irr\src\tools\go\pygo-win\BuildTools\vc\tools\msvc\14.35.32215\include -Iz:\home\kirr\src\tools\go\pygo-win\BuildTools\kits\10\i
    nclude\10.0.22000.0\shared -Iz:\home\kirr\src\tools\go\pygo-win\BuildTools\kits\10\include\10.0.22000.0\ucrt -Iz:\home\kirr\src\
    tools\go\pygo-win\BuildTools\kits\10\include\10.0.22000.0\um -Iz:\home\kirr\src\tools\go\pygo-win\BuildTools\kits\10\include\10.
    0.22000.0\winrt /Tc3rdparty/funchook/src/funchook.c /Fobuild\temp.win-amd64-cpython-310\Release\3rdparty/funchook/src/funchook.obj
    funchook.c
    3rdparty/funchook/src/funchook.c(61): error C2065: 'PATH_MAX': undeclared identifier
    3rdparty/funchook/src/funchook.c(61): error C2057: expected constant expression
    3rdparty/funchook/src/funchook.c(61): error C2466: cannot allocate an array of constant size 0
    3rdparty/funchook/src/funchook.c(84): fatal error C1189: #error:  unsupported OS or compiler
    error: command 'Z:\\home\\kirr\\src\\tools\\go\\pygo-win\\BuildTools\\vc\\tools\\msvc\\14.35.32215\\bin\\Hostx64\\x64\\cl.exe' f
    ailed with exit code 2

    https://stackoverflow.com/a/74084728/9456786
    https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170

also CMake on recent VisualStudio is reported not to define WIN32 as well

    https://developercommunity.visualstudio.com/t/win32-not-defined/722576

-> Fix this by using _WIN32 instead of WIN32 in the sources everywhere.

P.S. Thanks a lot for funchook!
@kubo kubo merged commit 7738ea4 into kubo:v1.x Jun 4, 2023
5 of 6 checks passed
@kubo
Copy link
Owner

kubo commented Jun 4, 2023

@navytux Thanks.

@navytux
Copy link
Contributor Author

navytux commented Jun 4, 2023

@kubo, thanks for applying my patch.

@navytux navytux deleted the v1.x-fix-win32 branch June 4, 2023 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants