public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: "Joakim Nohlgård" <joakim.nohlgard@eistec.se>
To: newlib@sourceware.org
Subject: stdatomic.h needs stdint.h (error: unknown type name 'int_least8_t')
Date: Wed, 22 Feb 2017 16:49:00 -0000	[thread overview]
Message-ID: <CAOy=vam5HbVarOiGNFx27jDCaNUNCe1qQg5EWzQJSEQg9AsZkQ@mail.gmail.com> (raw)

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

                 reply	other threads:[~2017-02-22 16:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOy=vam5HbVarOiGNFx27jDCaNUNCe1qQg5EWzQJSEQg9AsZkQ@mail.gmail.com' \
    --to=joakim.nohlgard@eistec.se \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).