From 3450df07b562f4c66af67f5b7f5d6e92c8fd3a3d Mon Sep 17 00:00:00 2001 From: Sergiu Deitsch Date: Fri, 25 Mar 2022 22:19:21 +0100 Subject: [PATCH] workaround msvc issue with C++17 consumer --- CXSparse/Include/cs.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CXSparse/Include/cs.h b/CXSparse/Include/cs.h index 2a7acff1a..1409392e3 100644 --- a/CXSparse/Include/cs.h +++ b/CXSparse/Include/cs.h @@ -31,6 +31,22 @@ #include "cs_export.h" #ifndef NCOMPLEX +/* + * A workaround for Visual Studio 2022 which does not define _Dcomplex if the + * consumer enabled the /std:c++17 flag. In this case, includes + * which in turn includes that omits the necessary type + * definition. + */ +#if defined(__cplusplus) && defined(_MSC_VER) +/* Adjust the definition of _CRT_USE_C_COMPLEX_H unless it is already defined + * and at the same time is non zero */ +# if !(defined(_CRT_USE_C_COMPLEX_H) && !_CRT_USE_C_COMPLEX_H) +# if defined(_CRT_USE_C_COMPLEX_H) +# undef _CRT_USE_C_COMPLEX_H +# endif +# define _CRT_USE_C_COMPLEX_H 1 +# endif +#endif #include #endif /* !defined(NCOMPLEX) */