This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Warning: imaginary constants are a GNU extension

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.

Parents
  • My other reply is pending investigation perhaps because of various links in it. The short reply is that using "i" (i.e. the small letter i) to create imaginary constants is not defined in the C standard (it is defined in C++14, but that std may not apply here as the question seems to be about C code), but such a facility is available for use if one is willing to utilize non-std extensions. If your code adheres to a std C11 or beyond, you can use CMPLX macros or __builtin_complex builtin function.

Reply
  • My other reply is pending investigation perhaps because of various links in it. The short reply is that using "i" (i.e. the small letter i) to create imaginary constants is not defined in the C standard (it is defined in C++14, but that std may not apply here as the question seems to be about C code), but such a facility is available for use if one is willing to utilize non-std extensions. If your code adheres to a std C11 or beyond, you can use CMPLX macros or __builtin_complex builtin function.

Children