-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.both
41 lines (27 loc) · 915 Bytes
/
types.both
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* This C/C++ file claims two definitions of qcomp, depending on who is asking.
* It tells both C and C++ compilers that qcomp is their native complex type.
*/
#ifndef TYPES_HPP
#define TYPES_HPP
#define MPI_QCOMP MPI_DOUBLE_COMPLEX
// when C++ parses this header, during C++ backend compilation, or during compilation of C++ user code...
#ifdef __cplusplus
// resolve qcomp as the C++ complex type
#include <complex>
typedef std::complex<double> qcomp;
// enable literals
using namespace std::complex_literals;
// when C parses this header, during compilation of C user code...
#else
// pretend that qcomp was the C complex type
#include <complex.h>
// which is either MSVC's custom C complex
#if _MSC_VER
typedef _Dcomplex qcomp;
// or that used by GNU & Clang
#else
typedef double complex qcomp;
#endif
#endif
#endif // TYPES_HPP