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

Failed to compile with MSVC 19.41.34120 amd64 Windows SDK 10.0.22621 #2450

Open
scuzqy opened this issue Jan 22, 2025 · 0 comments · May be fixed by #2451
Open

Failed to compile with MSVC 19.41.34120 amd64 Windows SDK 10.0.22621 #2450

scuzqy opened this issue Jan 22, 2025 · 0 comments · May be fixed by #2451

Comments

@scuzqy
Copy link
Contributor

scuzqy commented Jan 22, 2025

Build environment:
compiler: MSVC 19.41.34120.
generator: Ninja.
platform: Windows 10.0.19045 amd64.
Windows SDK 10.0.22621
CMAKE_CXX_FLAGS="/arch:AVX2 /W4"

Header from Windows sdk <rpcndr.h> introduced macro small as char alias
#define small char
compilation of math_test.cc fails when it reaches a template variable declaration const T small

<path/to/math_test.cc> error C2638: 'T' followed by ‘char’ is illegal (did you forget a ';'?)

(and hundreds of error lines)

Chain of include

"hwy/nanobenchmark.h" <= "hwy/timer.h" <= <windows.h> <= .... <= <rpcndr.h>

Possible fixes:

1 In hwy/timer.h"
change
#include <windows.h>
to

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif WIN32_LEAN_AND_MEAN
#include <windows.h>

This globally apply WIN32_LEAN_AND_MEAN to every file referencing hwy timer

2 Define WIN32_LEAN_AND_MEAN, but in math_test.cc, or a file closer to the beginning of include chain

3 Simply rename the var

@scuzqy scuzqy changed the title Failed to compile with MSVC 19.41.34120 amd64 Window 10.0.22621 Failed to compile with MSVC 19.41.34120 amd64 Windows SDK 10.0.22621 Jan 22, 2025
copybara-service bot pushed a commit that referenced this issue Jan 22, 2025
copybara-service bot pushed a commit that referenced this issue Jan 22, 2025
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 a pull request may close this issue.

1 participant