Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[C++] Fix Windows 32 bits compile and runtime failures (#11082)
### Motivation C++ source code cannot be compiled successfully for Windows 32-bit build. The compile error is: > fatal error C1021: invalid preprocessor command 'warning' It's because `#warning` preprocessor directive is not supported by MSVC compilers. And even if the related code was remove and the build succeeded, a example producer program would crash. This bug is introduced from #6129. It's because hardware CRC32 implementation on Windows is only provided for 64-bit programs. However, the `__cpuid` check in `crc32_initialize()` still returns true for 32-bit build, so finally it went here: ```c++ uint32_t crc32c(uint32_t init, const void *buf, size_t len, const chunk_config *config) { // SSE 4.2 extension for hw implementation are not present abort(); } ``` The `abort()` call will terminate the process. ### Modifications - Use `#pragma message()` to replace `#warning` if the compiler is MSVC. - Fallback to software implementation of CRC32 checksum algorithm if the hardware implementation is not supported. - Add the workflow to build Windows 32-bit C++ library. - Fix the wrong document about how to build it for Windows 32-bit.
- Loading branch information
1 parent
eafe7dd
commit c8fe1e8
Showing
4 changed files
with
22 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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