Re: Issue: CMPLX is not defined

Pavel M <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <CAL9Mx1uj7ZYaf9Z3Tu43BtWpZ-U1muofWzr3aXUEj9uQnixtnw@mail.gmail.com>
Thanks! Now I can compile clean (GCC only, Clang produces "error: use of
unknown builtin '__builtin_complex'").

On Tue, 10 May 2022 at 18:49, Joel Sherrill <[email protected]> wrote:

>
>
> On Tue, May 10, 2022 at 10:40 AM Pavel M <[email protected]> wrote:
>
>> Hi all,
>>
>> Issue: CMPLX is not defined.
>>
>> $ cat t649.c
>> #if __STDC_NO_COMPLEX__ != 1
>> #include <complex.h>
>> #ifndef CMPLX
>> #error
>> #endif
>> #endif
>>
>> $ gcc t649.c -std=c11 -pedantic -Wall -Wextra
>> t649.c:4:2: error: #error
>>     4 | #error
>>       |  ^~~~~
>>
>> C11:
>> > 7.3.9.3 The CMPLX macros
>>
>> Please fix.
>>
>
> If you really need these, they are simple to implement and patches are
> always welcomed. This is the entirety of the implementation for glibc:
>
> #if defined __USE_ISOC11 && __GNUC_PREREQ (4, 7)
> /* Macros to expand into expression of specified complex type.  */
> # define CMPLX(x, y) __builtin_complex ((double) (x), (double) (y))
> # define CMPLXF(x, y) __builtin_complex ((float) (x), (float) (y))
> # ifndef __NO_LONG_DOUBLE_MATH
> #  define CMPLXL(x, y) __builtin_complex ((long double) (x), (long double)
> (y))
> # endif
> #endif
>
> Should be a simple patch to complex.h
>
> --joel
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.