Closed misyltoad closed 2 years ago
I think the more robust test is actually __GXX_ABI_VERSION
compare to 1004.
Try out:
#if !defined(_XM_NO_XMVECTOR_OVERLOADS_) && (defined(__clang__) || (defined(__GNUC__) && (__GXX_ABI_VERSION < 1004)))
I'm trying GNUC 9.3.0 and I'm getting:
/home/walbourn/DirectXMath/Tests/../Inc/DirectXMath.h:477:33: error: ‘DirectX::XMVECTOR DirectX::operator+(DirectX::FXMVECTOR)’ must have an argument of class or enumerated type
477 | XMVECTOR XM_CALLCONV operator+ (FXMVECTOR V) noexcept;
Which is the error that indicates it doesn't support overloading of __m128
.
So as far as I can tell, GCC doesn't support this for intrinsics types like __m128
which is what _XM_NO_XMVECTOR_OVERLOADS_
is there for. Same is true for clang.
Perhaps you were building with _XM_NO_INTRINSICS_
which defines it's own struct XMVECTOR
which would work.
Ah yes, we define _XM_NO_INTRINSICS_
. Perhaps when this is defined we can always enable the overloads?
OK, that explains it.
Fixed in this commit.
Sorry to revive this. I'm on GCC which disables overloads. I am not defining _XM_NO_INTRINSICS_
. Yet, I can use operators. Expressions such as
min + scale * (XMVectorSet(x, y, z, 0) + 0.5)
work just fine (with min
, scale
being XMVECTOR
s). What's going on?
LOL. It seems that's a GCC feature (or quirk). The following program compiles:
#include <pmmintrin.h>
int main() {
__m128 x = _mm_set1_ps(1), y = _mm_set1_ps(2);
auto z = x + y * 0.5;
return 0;
}
Have you looked at SimpleMath?
In my experience, these work completely fine on a modern GCC.
This also adds a force macro to disable this functionality.