Python: Fix wrapper build on MSVC not having __cplusplus for BitHacks#613
Merged
axxel merged 1 commit intozxing-cpp:masterfrom Sep 7, 2023
Merged
Python: Fix wrapper build on MSVC not having __cplusplus for BitHacks#613axxel merged 1 commit intozxing-cpp:masterfrom
axxel merged 1 commit intozxing-cpp:masterfrom
Conversation
5 tasks
Collaborator
|
Thanks for looking into this and providing a fix. Before merging it though, I'd like to ask if you could test an alternative approach that I would consider a more general solution: diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index a06cd6e3..b49d4150 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -22,6 +22,11 @@ if (WINRT)
-DWINRT
)
endif()
+if (MSVC)
+ set (ZXING_CORE_DEFINES ${ZXING_CORE_DEFINES}
+ /Zc:__cplusplus
+ )
+else()
set (ZXING_CORE_LOCAL_DEFINES
$<$<BOOL:${BUILD_READERS}>:-DZXING_BUILD_READERS>
@@ -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}If that also fixes your issue, I'd commit that instead as it would also make sure that other client code that ends up including |
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 zxing-cpp#612
3ace3c1 to
82d38d5
Compare
Contributor
Author
|
Updated, it builds on MSVC |
Collaborator
|
Thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
BitHacks.hheader needs the__cplusplusdefine to determine whether to include<bit>. The MSVC compiler only defines this when it is passed the/Zc:__cplusplusflag. The main library was already setting this flag, but it not set when building the Python wrapper, causing compilation to fail becausecountr_zeroandpopcountare being used without<bit>being included.Fixes #612