Fix: Under Clang compilation constexpr variable 'INVALID_HANDLE' must be initialized by a constant expression#9049
Open
Khalyutin wants to merge 1 commit into
Conversation
…ANDLE)(LONG_PTR)-1)" as a constant - compilation error: constexpr variable 'INVALID_HANDLE' must be initialized by a constant expression ``` [build] 77 | constexpr static Handle INVALID_HANDLE = INVALID_HANDLE_VALUE; [build] /code/src/remote\../remote\../common/ThreadStart.h:77:26: error: constexpr variable 'INVALID_HANDLE' must be initialized by a constant expression [build] 77 | constexpr static Handle INVALID_HANDLE = INVALID_HANDLE_VALUE; [build] | ^ ~~~~~~~~~~~~~~~~~~~~ [build] /code/src/remote\../remote\../common/ThreadStart.h:77:43: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression [build] 77 | constexpr static Handle INVALID_HANDLE = INVALID_HANDLE_VALUE; [build] | ^ [build] C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um\handleapi.h:27:31: note: expanded from macro 'INVALID_HANDLE_VALUE' [build] 27 | #define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1) [build] | ^ ```
Contributor
|
Why not to return to |
Contributor
Author
We're trying to solve the problem of compiling and building CMake+Clang without changing the approaches adopted in Firebird to avoid things complicating... |
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 compiler does not consider "#define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1)" as a constant - compilation error: constexpr variable 'INVALID_HANDLE' must be initialized by a constant expression
In Windows 10.0.26100.0 INVALID_HANDLE_VALUE define C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um\handleapi.h as
#define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1)
clang interpret "((HANDLE)(.." as reinterpret_cast operation and raise error:
No excepton in MSVS compiler. Clang has more hard control of a constant expression...