I have a large code base that uses the c++
header and many std::complex
objects. But now I also want to use a couple
In C, _Complex
is a keyword used to declare complex numbers: float _Complex
. However, they #define complex _Complex
so you can write float complex
which looks nicer.
Of course, you get in trouble when using the name complex
in a context other than where you want _Complex
, such as std::complex
, which then expands to std::_Complex
.
So if you use <complex>
in C++, you should get rid of this macro:
#include <complex.h>
#undef complex
That's actually what g++ does since 4.8 to support both <complex>
and <complex.h>
in the same translation unit.
Note that when enabling C++11, you won't get the error either.