Skip to content

Fix build issues due to type conversions and missing includes

the-very requested to merge uint-to-int into master

Created by: ghost

I'm building this package in an environment with -Werror and -Wall, and getting these errors:

cpuid/cpuid.cpp(12,9): error: use of undeclared identifier '__cpuidex'
        __cpuidex(abcd, eax, ecx);
        ^
cpuid/cpuid.cpp(30,26): error: implicitly declaring library function '_xgetbv' with type 'unsigned long long (unsigned int) noexcept' [-Werror,-Wimplicit-function-declaration]
        xcr0 = (uint32_t)_xgetbv(0); /* min VS2010 SP1 compiler is required */
                         ^
cpuid/cpuid.cpp(30,26): note: include the header <immintrin.h> or explicitly provide a declaration for '_xgetbv'

Including the suggested header <immintrin.h> and adding <intrin.h> for undeclared identifier '__cpuidex' results in the following errors:

../../third_party/argon2/unsafe_internal/cpuid/cpuid.cpp(17,9): error: no matching function for call to '__cpuidex'
        __cpuidex(abcd, eax, ecx);
        ^~~~~~~~~
E:\edge\src\out\debug_x64\..\..\third_party\llvm-build\Release+Asserts\lib\clang\11.0.0\include\intrin.h(524,1): note: candidate function not viable: no known conversion from 'uint32_t *' (aka 'unsigned int *') to 'int *' for 1st argument
__cpuidex(int __info[4], int __level, int __ecx) {
^
1 error generated.

This PR makes appropriate changes to fix these issues.

Merge request reports