I need to include the header of a C library into my C++11 code. Now, the header provides routines and data structures that involve plenty of double complex
all over the place. E.g.,
#include <complex.h>
//..
typedef struct parameters
{
// ...
double complex Vud;
} parameters;
// ...
double complex polylog(int n, int m, double x);
I bring this file into my C++11 source wrapped in extern "C" { #include "include.h" }
(that's the actual filename, believe it or not). And g++ (tried 4.7.3 and 4.8.2) and clang (3.3) go nuts if I have -std=c++11 added.
The millions of lines of g++ errors include plenty of:
include/g++-v4/cmath:98:3: error: template with C linkage
And clang gives:
cmath:84:3: error: declaration conflicts with target of using declaration already in scope
abs(double __x)
^
/usr/include/stdlib.h:773:12: note: target of using declaration
extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
^
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include/g++-v4/cstdlib:245:14: note: using declaration
using std::abs;
^
I am not sure how to get around this. What is the correct way to do this? Clearly these must be inter-operable, but I do not know the trick.