Hello everyone,
I'm developing a code that involves complex number (complex.h).In every line that has the imaginary I, such as:
float complex sum = 0.0 + 0.0*I;
or
noise[j][i] = conjf(eigen_vec[i][k] + eigen_vec[i+m-1][k]*I);
Keil gives that warning: " imaginary constants are a GNU extension".
In the complex.h has:
define I _Complex_I
Why is it giving that warning?Is my code going to work properly?How can I solve that warning?Thanks in advanced.
Okay. So the header is ready to accept _Imaginary_I but only in non-GNU mode and only if __ARM_NO_IMAGINARY_TYPE is not defined.
If you copy the compiler command line including flags but without the input and output files, you can see the compilers preprocessor defines. For e.g., "gcc -xc -std=c11 --target=arm-arm-none-eabi -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -c -fno-rtti -funsigned-char -fshort-enums -fshort-wchar -dM -E - < /dev/null". I think that __ARM_NO_IMAGINARY_TYPE should turn out to be defined, and so there might actually be no _Imaginary_I support, even though the header has been ready to accept such types.
In that case, __extension__ is the workaround.
Thank you very much for your response and the others too.However, just out of curiosity, is there a way to modify __ARM_NO_IMAGINARY_TYPE? Where is that macro?
I think that it is a compiler-defined macro, so it must be in the compiler's source-code. The compiler must be setting its value depending on the flags passed and the actual features it can support.
Edit: One can undefine that macro by #undef, but that does not mean that the imaginary support also becomes available. If that macro is defined, it is an indication that the selected flags either prevent the compiler from providing the imaginary type, or that the compiler has no support for that type at all.