This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

stdatomic.h needs stdint.h (error: unknown type name 'int_least8_t')


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]