[cfe-users] Warnings with stdint.h?

2019-03-14 Thread Kumar Gala via cfe-users
I’m trying to build for ARM and was surprised to get warnings from the 
stdint.h.  Is this expected behavior?

Here’s what my c file looks like:

foo.c:
#include 

How I’m invoking the compiler:

/usr/bin/clang --target=arm-none-eabi -I/usr/lib64/clang/7.0.1/include 
-nostdinc  -c foo.c

I’m surprised to see the following warnings get generated with 
/usr/lib64/clang/7.0.1/include/stdint.h:

In file included from foo.c:1:
/usr/lib64/clang/7.0.1/include/stdint.h:186:10: warning: '__int_least32_t' 
macro redefined [-Wmacro-redefined]
# define __int_least32_t int32_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:112:10: note: previous definition is 
here
# define __int_least32_t int64_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:187:10: warning: '__uint_least32_t' 
macro redefined [-Wmacro-redefined]
# define __uint_least32_t uint32_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:113:10: note: previous definition is 
here
# define __uint_least32_t uint64_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:188:10: warning: '__int_least16_t' 
macro redefined [-Wmacro-redefined]
# define __int_least16_t int32_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:114:10: note: previous definition is 
here
# define __int_least16_t int64_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:189:10: warning: '__uint_least16_t' 
macro redefined [-Wmacro-redefined]
# define __uint_least16_t uint32_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:115:10: note: previous definition is 
here
# define __uint_least16_t uint64_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:190:10: warning: '__int_least8_t' macro 
redefined [-Wmacro-redefined]
# define __int_least8_t int32_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:116:10: note: previous definition is 
here
# define __int_least8_t int64_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:191:10: warning: '__uint_least8_t' 
macro redefined [-Wmacro-redefined]
# define __uint_least8_t uint32_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:117:10: note: previous definition is 
here
# define __uint_least8_t uint64_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:219:10: warning: '__int_least16_t' 
macro redefined [-Wmacro-redefined]
# define __int_least16_t int16_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:188:10: note: previous definition is 
here
# define __int_least16_t int32_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:220:10: warning: '__uint_least16_t' 
macro redefined [-Wmacro-redefined]
# define __uint_least16_t uint16_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:189:10: note: previous definition is 
here
# define __uint_least16_t uint32_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:221:10: warning: '__int_least8_t' macro 
redefined [-Wmacro-redefined]
# define __int_least8_t int16_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:190:10: note: previous definition is 
here
# define __int_least8_t int32_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:222:10: warning: '__uint_least8_t' 
macro redefined [-Wmacro-redefined]
# define __uint_least8_t uint16_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:191:10: note: previous definition is 
here
# define __uint_least8_t uint32_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:238:10: warning: '__int_least8_t' macro 
redefined [-Wmacro-redefined]
# define __int_least8_t int8_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:221:10: note: previous definition is 
here
# define __int_least8_t int16_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:239:10: warning: '__uint_least8_t' 
macro redefined [-Wmacro-redefined]
# define __uint_least8_t uint8_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:222:10: note: previous definition is 
here
# define __uint_least8_t uint16_t
 ^
/usr/lib64/clang/7.0.1/include/stdint.h:376:11: warning: '__int32_c_suffix' 
macro redefined [-Wmacro-redefined]
#  define __int32_c_suffix __INT32_C_SUFFIX__
  ^
/usr/lib64/clang/7.0.1/include/stdint.h:301:11: note: previous definition is 
here
#  define __int32_c_suffix __INT64_C_SUFFIX__
  ^
/usr/lib64/clang/7.0.1/include/stdint.h:377:11: warning: '__int16_c_suffix' 
macro redefined [-Wmacro-redefined]
#  define __int16_c_suffix __INT32_C_SUFFIX__
  ^
/usr/lib64/clang/7.0.1/include/stdint.h:302:11: note: previous definition is 
here
#  define __int16_c_suffix __INT64_C_SUFFIX__
  ^
/usr/lib64/clang/7.0.1/include/stdint.h:378:11: warning: '__int8_c_suffix' 
macro redefined [-Wmacro-redefined]
#  define __int8_c_suffix  __INT32_C_SUFFIX__
  ^
/usr/lib64/clang/7.0.1/include/stdint.h:303:12: note: previous definition is 
here
#  define  __int8_c_suffix __INT64_C_SUFFIX__
   ^
/usr/lib64/clang/7.0.1/include/stdint.h:414:11: warning: '__int16_c_suffix' 
macro redefined [-Wmacro-redefined]
#  define __int16_c_suffix __INT16_C_SUFFIX__
  ^
/usr/lib64/clang/7.0.1/include/stdint.h:377:11: note: previo

Re: [cfe-users] Warnings with stdint.h?

2019-03-14 Thread Peter Smith via cfe-users
Hello Kumar, (reposting as I wasn't subscribed to cfe-users).

Yes I think that these warnings are expected when the clang stdint.h
is included via -I. Normally it is included as a system header which
suppresses the warnings (-isystem).  From the comment in
https://github.com/llvm-mirror/clang/blob/master/lib/Headers/stdint.h#L89
it looks like the redefinitions are expected and that clang is relying
on the warnings to be suppressed.

Another way to reproduce is to turn on warnings in system headers:
clang -c foo.c -ffreestanding -Wsystem-headers

Peter

On Thu, 14 Mar 2019 at 15:39, Kumar Gala  wrote:
>
> I’m trying to build for ARM and was surprised to get warnings from the 
> stdint.h.  Is this expected behavior?
>
> Here’s what my c file looks like:
>
> foo.c:
> #include 
>
> How I’m invoking the compiler:
>
> /usr/bin/clang --target=arm-none-eabi -I/usr/lib64/clang/7.0.1/include 
> -nostdinc  -c foo.c
>
> I’m surprised to see the following warnings get generated with 
> /usr/lib64/clang/7.0.1/include/stdint.h:
>
> In file included from foo.c:1:
> /usr/lib64/clang/7.0.1/include/stdint.h:186:10: warning: '__int_least32_t' 
> macro redefined [-Wmacro-redefined]
> # define __int_least32_t int32_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:112:10: note: previous definition is 
> here
> # define __int_least32_t int64_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:187:10: warning: '__uint_least32_t' 
> macro redefined [-Wmacro-redefined]
> # define __uint_least32_t uint32_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:113:10: note: previous definition is 
> here
> # define __uint_least32_t uint64_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:188:10: warning: '__int_least16_t' 
> macro redefined [-Wmacro-redefined]
> # define __int_least16_t int32_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:114:10: note: previous definition is 
> here
> # define __int_least16_t int64_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:189:10: warning: '__uint_least16_t' 
> macro redefined [-Wmacro-redefined]
> # define __uint_least16_t uint32_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:115:10: note: previous definition is 
> here
> # define __uint_least16_t uint64_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:190:10: warning: '__int_least8_t' 
> macro redefined [-Wmacro-redefined]
> # define __int_least8_t int32_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:116:10: note: previous definition is 
> here
> # define __int_least8_t int64_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:191:10: warning: '__uint_least8_t' 
> macro redefined [-Wmacro-redefined]
> # define __uint_least8_t uint32_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:117:10: note: previous definition is 
> here
> # define __uint_least8_t uint64_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:219:10: warning: '__int_least16_t' 
> macro redefined [-Wmacro-redefined]
> # define __int_least16_t int16_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:188:10: note: previous definition is 
> here
> # define __int_least16_t int32_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:220:10: warning: '__uint_least16_t' 
> macro redefined [-Wmacro-redefined]
> # define __uint_least16_t uint16_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:189:10: note: previous definition is 
> here
> # define __uint_least16_t uint32_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:221:10: warning: '__int_least8_t' 
> macro redefined [-Wmacro-redefined]
> # define __int_least8_t int16_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:190:10: note: previous definition is 
> here
> # define __int_least8_t int32_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:222:10: warning: '__uint_least8_t' 
> macro redefined [-Wmacro-redefined]
> # define __uint_least8_t uint16_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:191:10: note: previous definition is 
> here
> # define __uint_least8_t uint32_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:238:10: warning: '__int_least8_t' 
> macro redefined [-Wmacro-redefined]
> # define __int_least8_t int8_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:221:10: note: previous definition is 
> here
> # define __int_least8_t int16_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:239:10: warning: '__uint_least8_t' 
> macro redefined [-Wmacro-redefined]
> # define __uint_least8_t uint8_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:222:10: note: previous definition is 
> here
> # define __uint_least8_t uint16_t
>  ^
> /usr/lib64/clang/7.0.1/include/stdint.h:376:11: warning: '__int32_c_suffix' 
> macro redefined [-Wmacro-redefined]
> #  define __int32_c_suffix __INT32_C_SUFFIX__
>   ^
> /usr/lib64/clang/7.0.1/include/stdint.h:301:11: note: previous definition is 
> here
> #  define __int32_c_suffix __INT64_C_SUFFIX__
>   ^
> /usr/l

Re: [cfe-users] Warnings with stdint.h?

2019-03-14 Thread Kumar Gala via cfe-users
Ah the bit about -isystem and suppressing warnings was good to know.  For a few 
cases in our build system we didn’t have -isystem for 
/usr/lib64/clang/7.0.1/include.

- k

> On Mar 14, 2019, at 11:23 AM, Peter Smith  wrote:
> 
> Hello Kumar, (reposting as I wasn't subscribed to cfe-users).
> 
> Yes I think that these warnings are expected when the clang stdint.h
> is included via -I. Normally it is included as a system header which
> suppresses the warnings (-isystem).  From the comment in
> https://github.com/llvm-mirror/clang/blob/master/lib/Headers/stdint.h#L89
> it looks like the redefinitions are expected and that clang is relying
> on the warnings to be suppressed.
> 
> Another way to reproduce is to turn on warnings in system headers:
> clang -c foo.c -ffreestanding -Wsystem-headers
> 
> Peter
> 
> On Thu, 14 Mar 2019 at 15:39, Kumar Gala  wrote:
>> 
>> I’m trying to build for ARM and was surprised to get warnings from the 
>> stdint.h.  Is this expected behavior?
>> 
>> Here’s what my c file looks like:
>> 
>> foo.c:
>> #include 
>> 
>> How I’m invoking the compiler:
>> 
>> /usr/bin/clang --target=arm-none-eabi -I/usr/lib64/clang/7.0.1/include 
>> -nostdinc  -c foo.c
>> 
>> I’m surprised to see the following warnings get generated with 
>> /usr/lib64/clang/7.0.1/include/stdint.h:
>> 
>> In file included from foo.c:1:
>> /usr/lib64/clang/7.0.1/include/stdint.h:186:10: warning: '__int_least32_t' 
>> macro redefined [-Wmacro-redefined]
>> # define __int_least32_t int32_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:112:10: note: previous definition is 
>> here
>> # define __int_least32_t int64_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:187:10: warning: '__uint_least32_t' 
>> macro redefined [-Wmacro-redefined]
>> # define __uint_least32_t uint32_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:113:10: note: previous definition is 
>> here
>> # define __uint_least32_t uint64_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:188:10: warning: '__int_least16_t' 
>> macro redefined [-Wmacro-redefined]
>> # define __int_least16_t int32_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:114:10: note: previous definition is 
>> here
>> # define __int_least16_t int64_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:189:10: warning: '__uint_least16_t' 
>> macro redefined [-Wmacro-redefined]
>> # define __uint_least16_t uint32_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:115:10: note: previous definition is 
>> here
>> # define __uint_least16_t uint64_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:190:10: warning: '__int_least8_t' 
>> macro redefined [-Wmacro-redefined]
>> # define __int_least8_t int32_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:116:10: note: previous definition is 
>> here
>> # define __int_least8_t int64_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:191:10: warning: '__uint_least8_t' 
>> macro redefined [-Wmacro-redefined]
>> # define __uint_least8_t uint32_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:117:10: note: previous definition is 
>> here
>> # define __uint_least8_t uint64_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:219:10: warning: '__int_least16_t' 
>> macro redefined [-Wmacro-redefined]
>> # define __int_least16_t int16_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:188:10: note: previous definition is 
>> here
>> # define __int_least16_t int32_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:220:10: warning: '__uint_least16_t' 
>> macro redefined [-Wmacro-redefined]
>> # define __uint_least16_t uint16_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:189:10: note: previous definition is 
>> here
>> # define __uint_least16_t uint32_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:221:10: warning: '__int_least8_t' 
>> macro redefined [-Wmacro-redefined]
>> # define __int_least8_t int16_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:190:10: note: previous definition is 
>> here
>> # define __int_least8_t int32_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:222:10: warning: '__uint_least8_t' 
>> macro redefined [-Wmacro-redefined]
>> # define __uint_least8_t uint16_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:191:10: note: previous definition is 
>> here
>> # define __uint_least8_t uint32_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:238:10: warning: '__int_least8_t' 
>> macro redefined [-Wmacro-redefined]
>> # define __int_least8_t int8_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:221:10: note: previous definition is 
>> here
>> # define __int_least8_t int16_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:239:10: warning: '__uint_least8_t' 
>> macro redefined [-Wmacro-redefined]
>> # define __uint_least8_t uint8_t
>> ^
>> /usr/lib64/clang/7.0.1/include/stdint.h:222:10: note: previous definition is 
>> here
>> # define __uint_least8_t ui