Skip to content

Commit 3450df0

Browse files
committed
workaround msvc issue with C++17 consumer
1 parent 5d418c4 commit 3450df0

File tree

1 file changed

+16
-0
lines changed
  • CXSparse/Include

1 file changed

+16
-0
lines changed

CXSparse/Include/cs.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@
3131
#include "cs_export.h"
3232

3333
#ifndef NCOMPLEX
34+
/*
35+
* A workaround for Visual Studio 2022 which does not define _Dcomplex if the
36+
* consumer enabled the /std:c++17 flag. In this case, <complex.h> includes
37+
* <ccomplex> which in turn includes <complex> that omits the necessary type
38+
* definition.
39+
*/
40+
#if defined(__cplusplus) && defined(_MSC_VER)
41+
/* Adjust the definition of _CRT_USE_C_COMPLEX_H unless it is already defined
42+
* and at the same time is non zero */
43+
# if !(defined(_CRT_USE_C_COMPLEX_H) && !_CRT_USE_C_COMPLEX_H)
44+
# if defined(_CRT_USE_C_COMPLEX_H)
45+
# undef _CRT_USE_C_COMPLEX_H
46+
# endif
47+
# define _CRT_USE_C_COMPLEX_H 1
48+
# endif
49+
#endif
3450
#include <complex.h>
3551
#endif /* !defined(NCOMPLEX) */
3652

0 commit comments

Comments
 (0)