I am mixing C with C++ source code using GNU. _Decimal64
is recognised fine in C, but not in C++. C++ complains error: '_Decimal64' does not name a type
.
Is there any way I can fix this? Should I consider it a compiler bug?
Update 20-Mar-2017 18:19:
None of the answers meet my requirements so far. I don't want to use the decimal64
C++ class, I want to use the _Decimal64
C type. My project is mostly written in C, but I want to slowly introduce C++ code. Here, for example, is part of cell.h
:
union vals
{
num c_n;
//double c_d;
char *c_s;
long c_l;
int c_i;
struct rng c_r;
};
It is made use of in cells.c
, which of course is C code. num
is defined in numeric.h
:
#pragma once
#ifdef __cplusplus
#define USE_DECIMAL 0
#else
#define USE_DECIMAL 1
#endif
#if USE_DECIMAL
typedef _Decimal64 num;
#define NUM_HUNDREDTH 0.01DL
#define NUM_TEN 10.0DL
#else
typedef double num;
#define NUM_HUNDREDTH 0.01
#define NUM_TEN 10.0
#endif
Notice that I have use typedef double num
to get a compile on the C++ side. C++ doesn't actually num
type, but it is inevitably included because it needs some of the functionality in the C files.
It's faking it, of course.num
isn't a double, it's really a _Decimal64
. I'm asking how I can get around this kludge.