public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* stdatomic.h needs stdint.h (error: unknown type name 'int_least8_t')
@ 2017-02-22 16:49 Joakim Nohlgård
  0 siblings, 0 replies; only message in thread
From: Joakim Nohlgård @ 2017-02-22 16:49 UTC (permalink / raw)
  To: newlib

Dear developers,
In newlib/libc/include/stdatomic.h there are several typedefs on the form:

typedef _Atomic(int_least8_t) atomic_int_least8_t;

These cause a compiler error about an unknown type int_least8_t unless
<stdint.h> is explicitly included beforehand.
They should either be changed to underscored type names __int_least8_t
defined in sys/_types.h, or an #include <stdint.h> should be added at
the top of stdatomic.h.

Also, Newlib's stdatomic.h is broken when using GCC (__GNUC_ATOMICS),
verified broken with versions 5.4.0 and 6.3.0 for arm-none-eabi
target, so I used Clang 3.9.1 as the compiler in my examples below. It
works with GCC-4.6.3 which uses the __sync atomics instead.

Minimal example test case:

% echo '#include <stdint.h>\n#include <stdatomic.h>' \
 | clang -nostdinc -isystem \
/usr/arm-none-eabi/include \
-isystem /usr/lib/gcc/arm-none-eabi/6.3.0/include \
-x c -o /dev/null -c -

Works fine.

The below does not:

% echo '#include <stdatomic.h>' \
 | clang -nostdinc -isystem \
/usr/arm-none-eabi/include \
-isystem /usr/lib/gcc/arm-none-eabi/6.3.0/include \
-x c -o /dev/null -c -

In file included from <stdin>:1:
/usr/arm-none-eabi/include/stdatomic.h:204:17: error: unknown type
name 'int_least8_t'; did you mean '__int_least8_t'?
typedef _Atomic(int_least8_t)           atomic_int_least8_t;
                ^
/usr/arm-none-eabi/include/machine/_default_types.h:134:29: note:
'__int_least8_t' declared here
typedef __INT_LEAST8_TYPE__ __int_least8_t;
                            ^
In file included from <stdin>:1:
/usr/arm-none-eabi/include/stdatomic.h:205:17: error: unknown type
name 'uint_least8_t'
typedef _Atomic(uint_least8_t)          atomic_uint_least8_t;
                ^
/usr/arm-none-eabi/include/stdatomic.h:206:17: error: unknown type
name 'int_least16_t'; did you mean
      '__int_least16_t'?
typedef _Atomic(int_least16_t)          atomic_int_least16_t;
                ^

The errors go on further, but they are all about missing types.

Best regards,
Joakim Nohlgård
Eistec AB

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-02-22 16:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-22 16:49 stdatomic.h needs stdint.h (error: unknown type name 'int_least8_t') Joakim Nohlgård

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).