Skip to content

Commit

Permalink
Python: Fix wrapper build on MSVC not having __cplusplus for BitHacks
Browse files Browse the repository at this point in the history
The `BitHacks.h` header needs the `__cplusplus` define to determine
whether to include `<bit>`. The MSVC compiler only defines this when it
is passed the `/Zc:__cplusplus` flag. The main library was already
setting this flag, but it not set when building the Python wrapper,
causing compilation to fail because `countr_zero` and `popcount` are
being used without `<bit>` being included.

Fixes #612
  • Loading branch information
EchterAgo committed Sep 7, 2023
1 parent 81b405b commit 82d38d5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ if (WINRT)
-DWINRT
)
endif()
if (MSVC)
set (ZXING_CORE_DEFINES ${ZXING_CORE_DEFINES}
/Zc:__cplusplus
)
endif()

set (ZXING_CORE_LOCAL_DEFINES
$<$<BOOL:${BUILD_READERS}>:-DZXING_BUILD_READERS>
Expand All @@ -34,7 +39,6 @@ if (MSVC)
-D_CRT_SECURE_NO_WARNINGS
-D_CRT_NONSTDC_NO_WARNINGS
-DNOMINMAX
/Zc:__cplusplus
)
else()
set (ZXING_CORE_LOCAL_DEFINES ${ZXING_CORE_LOCAL_DEFINES}
Expand Down

0 comments on commit 82d38d5

Please sign in to comment.