Skip to content

Commit 6f6ef23

Browse files
committed
interface: Start MSVC fixes
MSVC does not support C complex numbers. There's a different approach here. Thus, we try to fix it with some additional burden. Let's poke the CI. Signed-off-by: Johannes Demel <[email protected]>
1 parent 043099a commit 6f6ef23

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

include/volk/volk_complex.h

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <volk/volk_common.h>
2222

2323
__VOLK_DECL_BEGIN
24-
24+
#ifndef __STDC_NO_COMPLEX__
2525
// Obviously, we would love `typedef float complex lv_32fc_t` to work.
2626
// However, this clashes with C++ definitions.
2727
// error: expected initializer before ‘lv_32fc_t’
@@ -35,6 +35,37 @@ typedef long long _Complex lv_64sc_t;
3535
typedef float _Complex lv_32fc_t;
3636
typedef double _Complex lv_64fc_t;
3737

38+
#else
39+
// MSVC requires different treatment.
40+
// https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-160
41+
// https://docs.microsoft.com/en-us/cpp/c-runtime-library/complex-math-support?view=msvc-160
42+
// Refer to `complex.h` in
43+
// https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/
44+
45+
typedef _Fcomplex lv_32fc_t;
46+
typedef _Dcomplex lv_64fc_t;
47+
48+
// typedef char _Complex lv_8sc_t;
49+
typedef struct lv_8sc_t {
50+
char _Val[2];
51+
} lv_8sc_t;
52+
53+
// typedef short _Complex lv_16sc_t;
54+
typedef struct lv_16sc_t {
55+
short _Val[2];
56+
} lv_16sc_t;
57+
58+
// typedef long _Complex lv_32sc_t;
59+
typedef struct lv_32sc_t {
60+
long _Val[2];
61+
} lv_32sc_t;
62+
63+
// typedef long long _Complex lv_64sc_t;
64+
typedef struct lv_64sc_t {
65+
long long _Val[2];
66+
} lv_64sc_t;
67+
#endif
68+
3869
#define lv_cmake(r, i) ((r) + _Complex_I * (i))
3970
// We want `_Imaginary_I` to ensure the correct sign.
4071
// https://en.cppreference.com/w/c/numeric/complex/Imaginary_I

0 commit comments

Comments
 (0)