The following code builds just fine under cl
, but fails under clang-cl
:
#define NUDGE_FORCEINLINE __forceinline
NUDGE_FORCEINLINE __m128 operator-(__m128 a) {
return _mm_xor_ps(a, _mm_set1_ps(-0.0f));
}
This is the error message:
..\nudge.cpp(65,26): error: overloaded 'operator-' must have at least one parameter of class or enumeration type
NUDGE_FORCEINLINE __m128 operator-(__m128 a) {
^
The code is from rasmusbarr/nudge, an experiment which seems to be abandoned since 2017.
Setup (CMake/VSCode):
cl
withVS Build Tools 2019 v16.8.2
clang-cl
withC++ Clang Tools for Windows 10.0.0 (VS Build Tools 2019 v16.8.2)
cmake_minimum_required(VERSION 3.18.0)
project(nudge LANGUAGES C CXX)
add_executable(tests "nudge.cpp" "tests/main.cpp")
target_include_directories(tests PRIVATE ${CMAKE_SOURCE_DIR})
Research:
I came across these two sources (1, 2) that seem to point out that the reason might be clang-cl does not consider __m128 to be a struct type. They fixed it in (1), but it seems that they just disable SSE for some platforms.
Although it was a long shot, I tried compiling with the VS version of immintrin.h
and intrin.h
but that path led nowhere.
I also noticed that someone else who build this experiment used the c++11 standard so I tried that too by setting set(CMAKE_CXX_STANDARD 11)
in cmake. No change.
Question:
How can I modify the code (or change compiler flags) in order to build rasmusbarr/nudge with clang-cl?
Thank you