XXH_STATIC_ASSERT() doesn't work with VC++2019 as a C compiler #567
Labels
No labels
announcement
bug
build
CI
dependencies
documentation
duplicate
enhancement
experience feedback
feature request
github_actions
help wanted
install
invalid
Long-term
optimization
portability
question
target-specific
test issue
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Cyan4973/xxHash#567
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When we compile a code with Visual C++ 2019 as a C compiler, it doesn't interpret
XXH_STATIC_ASSERT(0)properly.If we use Visual C++ 2019 as a C++ compiler,
XXH_STATIC_ASSERT(0)works correctly though.When we compile above code as
test.cpp, VC++2019 reports the following error.But compile as
test.c, it reports nothing.At Compiler Explorer, it seems VC++ as a C compiler is only compiler which accepts above
f()without error / warning.I don't know there's a compiler switch to disable this behavior.
(edit)
/std:c11,/std:c17don't change the behavior._Static_assert()works. But it requires recent version of MSVC and Windows SDK. MSVC2019 isn't shipped with<stdalign.h>etc.I think it's a good chance to introduce standard
static_assert().<assert.h>,static_assert()and _Static_assertstatic_assert()Both of them have same form:
static_assert( <cond> , "<message>" ).Still we need discussion how we can implement
static_assert()for pre-C11 and MSVC (as a C) compilers. But it might look like this:I'm fine with the idea of an improved version of
XXH_STATIC_ASSERT()that remains compatible withC90.