public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* Issue: CMPLX is not defined
@ 2022-05-10 15:39 Pavel M
  2022-05-10 15:49 ` Joel Sherrill
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel M @ 2022-05-10 15:39 UTC (permalink / raw)
  To: newlib

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Issue: CMPLX is not defined
  2022-05-10 15:39 Issue: CMPLX is not defined Pavel M
@ 2022-05-10 15:49 ` Joel Sherrill
  2022-05-10 18:09   ` Pavel M
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Sherrill @ 2022-05-10 15:49 UTC (permalink / raw)
  To: Pavel M; +Cc: Newlib

On Tue, May 10, 2022 at 10:40 AM Pavel M <pavel.morozkin@gmail.com> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Issue: CMPLX is not defined
  2022-05-10 15:49 ` Joel Sherrill
@ 2022-05-10 18:09   ` Pavel M
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel M @ 2022-05-10 18:09 UTC (permalink / raw)
  To: joel; +Cc: Newlib

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 <joel@rtems.org> wrote:

>
>
> On Tue, May 10, 2022 at 10:40 AM Pavel M <pavel.morozkin@gmail.com> 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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-10 18:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 15:39 Issue: CMPLX is not defined Pavel M
2022-05-10 15:49 ` Joel Sherrill
2022-05-10 18:09   ` Pavel M

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).