From 9b13f0f4189c4863cf4ea2eb93a4d7c895344fed Mon Sep 17 00:00:00 2001 From: Bruno Cabral Date: Mon, 1 Jul 2024 19:25:08 -0700 Subject: [PATCH] [raymath.h] use CLITERAL for MSVC --- src/raymath.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/raymath.h b/src/raymath.h index 0b6951938..2585bded7 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -77,6 +77,17 @@ #endif #endif +// NOTE: MSVC C++ compiler does not support compound literals (C99 feature) +// Plain structures in C++ (without constructors) can be initialized with { } +// This is called aggregate initialization (C++11 feature) +#ifndef CLITERAL + #if defined(__cplusplus) + #define CLITERAL(type) type + #else + #define CLITERAL(type) (type) + #endif +#endif + //---------------------------------------------------------------------------------- // Defines and Macros @@ -2549,9 +2560,9 @@ RMAPI void MatrixDecompose(Matrix mat, Vector3 *translation, Quaternion *rotatio // Extract scale const float det = a*A + b*B + c*C; - float scalex = Vector3Length((Vector3){ a, b, c }); - float scaley = Vector3Length((Vector3){ d, e, f }); - float scalez = Vector3Length((Vector3){ g, h, i }); + float scalex = Vector3Length(CLITERAL(Vector3){ a, b, c }); + float scaley = Vector3Length(CLITERAL(Vector3){ d, e, f }); + float scalez = Vector3Length(CLITERAL(Vector3){ g, h, i }); Vector3 s = { scalex, scaley, scalez }; if (det < 0) s = Vector3Negate(s);