Skip to content

Commit

Permalink
BitHacks: fix MSVC build when /Zc:__cplusplus is not set on client side
Browse files Browse the repository at this point in the history
This fixes zxing-cpp#863.
  • Loading branch information
axxel committed Nov 5, 2024
1 parent 8ad13cb commit cd9bba3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/src/BitHacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
#include <cstring>
#include <vector>

#if __has_include(<bit>) && __cplusplus > 201703L // MSVC has the <bit> header but then warns about including it
// MSVC has the <bit> header but then warns about including it.
// We check for _MSVC_LANG here as well, so client code is depending on /Zc:__cplusplus
#if __has_include(<bit>) && (__cplusplus > 201703L || _MSVC_LANG > 201703L)
#include <bit>
#if __cplusplus > 201703L && defined(__ANDROID__) // NDK 25.1.8937393 has the implementation but fails to advertise it
#define __cpp_lib_bitops 201907L
#endif
#elif defined(_MSC_VER)
// accoring to #863 MSVC defines __cpp_lib_bitops even when <bit> it not included and bitops are not available
#undef __cpp_lib_bitops
#endif

#if defined(__clang__) || defined(__GNUC__)
Expand Down

0 comments on commit cd9bba3

Please sign in to comment.