I am compiling a library with Petsc using Clang 3.4 and get:
error: use of undeclared identifier 'creal'
it follows from the following define:
petscmath.h:121:38: note: expanded from macro 'PetscRealPartComplex'
#define PetscRealPartComplex(a) creal(a)
the only relevant info i can find is this, i don't know if this is something compiler-specific and some libraries are missing or i have some problems with Petsc.
I tried using `cimag()' as it is in a small test file, but i can't compile it with neither clang3.4 nor gcc4.8.
Anyone has any ideas what is happening. Google does not show any similar topics...
EDIT:
so here is a simple example:
#include <complex.h>
int main ()
{
double complex z;
double cc = cimag(z);
}
it does compile with Gcc4.8 (from macports): g++-mp-4.8 main.cc -o main
however in c11 mode it does not : g++-mp-4.8 -std=c++11 main.cc -o main
:
expected initializer before 'z' double complex z;
clang does not compile it in either cases and produce the same error as above.
Reference: http://pubs.opengroup.org/onlinepubs/7999959899/basedefs/complex.h.html
Reference: http://en.cppreference.com/w/c/numeric/complex
Note that I get the same results when specifying
-std=c++11
with GCC, but not-x c -std=c11
. YMMV.