Fix ssize_t int redefinition error on Windows#847
Open
uilianries wants to merge 1 commit intostephane:masterfrom
Open
Fix ssize_t int redefinition error on Windows#847uilianries wants to merge 1 commit intostephane:masterfrom
uilianries wants to merge 1 commit intostephane:masterfrom
Conversation
Mitigates the MSVC error: src\modbus-private.h(19): error C2632: 'int' followed by 'int' is illegal ssize_t is defined already on MSVC which causes the error Signed-off-by: Uilian Ries <uilianries@gmail.com>
|
We require contributors to sign our Contributor License Agreement. In order for us to review and merge your code, please fill https://forms.gle/5635zjphDo5JEJQSA to get added. Your document will be manually checked by the maintainer. Be patient... |
Author
Done. The CLA form has been filled and sent. Regards! |
4 tasks
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.
Greetings!
When building libmodbus 3.1.12 on Windows with MSVC, the following error is listed:
The full build log can be found here: https://c3i.jfrog.io/artifactory/cci-build-logs/cci/prod/PR-30083/4/package_build_logs/build_log_libmodbus_3_1_12_b07e4eebf5b5cd0ff2c2ef1dc2a0bfbe_19e318a866610969ae17aaa36552350ac86725f0.txt
We noted that error when packaging libmodbus for Conan Center, on the PR conan-io/conan-center-index#30083. And may be related to 23dd803
As the type ssize_t is POSIX, when running
configureon Windows, the setup can't findssize_tvia AC_TYPE_SSIZE_T and writes#define ssize_t intintoconfig.has a result. Then, whenconfig.hgets included before thattypedef, the preprocessor expandstypedef int ssize_tintotypedef int int, which is invalid by the msvc compiler.This PR adds a guard to prevent redefining
ssize_t, so mitigating this error as on Linux and other will not have effect, but on Windows will really consume the already definedssize_tfromconfig.h. This idea is actually being used by the Conan recipe for libmodbus on previous version too.I tested this patch locally, over libmodbus 3.1.12 on Windows: libmodbus-3.1.12-windows-amd64-msvc194-release-static-patched.log
Regards!
Environment
OS: Windows
CPU: x86_64
Build type: Release
Compiler: Visual Studio - MSVC 194
Libmodbus version: 3.1.12