public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* __INT_FAST*_TYPE__ undefined
@ 2016-08-21  9:41 Kévin
  2016-08-21 18:58 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Kévin @ 2016-08-21  9:41 UTC (permalink / raw)
  To: newlib

Hi,

I have an issue with compiling using newlib and stdint.

issue
-----

when I compile against newlib I get the following error:

clang -target arm-none-eabi -Os -g -std=c99 -nostdlib -nostdinc -fno-common -ffunction-sections -fdata-sections -ffreestanding -Wpedantic -Wall -Werror -Wextra -Wundef -Wshadow -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes -Wstrict-overflow=5 -I/usr/include/newlib/ -I/usr/lib/gcc/arm-none-eabi/*/include/ -I. -mthumb -mcpu=cortex-m3 -o global.o -c global.c
In file included from global.c:21:
In file included from /usr/include/newlib/stdint.h:13:
/usr/include/newlib/sys/_intsup.h:118:6: error: '__INT_FAST8_TYPE__' is not defined, evaluates to 0 [-Werror,-Wundef]
#if (__INT_FAST8_TYPE__ == 0)
...

analysis
--------

global.c:21 is the following
#include <stdint.h> // standard integer types

I am not using the system library but newlib (-nostdlib -nostdinc -I/usr/include/newlib/)
thus the stdint.h included is /usr/include/newlib/stdint.h

stdint.h has the following (unconditional) include:
#include <sys/_intsup.h>

_intsup.h has the following defines:
#if (__INT_FAST8_TYPE__ == 0)
#define __FAST8 "hh"
#elif (__INT_FAST8_TYPE__ == 1 || __INT_FAST8_TYPE__ == 3)
#define __FAST8 "h"
#elif (__INT_FAST8_TYPE__ == 2)
#define __FAST8
#elif (__INT_FAST8_TYPE__ == 4 || __INT_FAST8_TYPE__ == 6)
#define __FAST8 "l"
#elif (__INT_FAST8_TYPE__ == 8 || __INT_FAST8_TYPE__ == 10)
#define __FAST8 "ll"
#endif
this applies to other _INT_FAST and _INT_LEAST

but __INT_FAST8_TYPE__ is not defined anywhere in newlib, thus clang complains because I am using (-Werror -Wundef).

solution
--------

__INT_FAST8_TYPE__ might be defined in another library such but not in the ones I use/include.

sys/_intsup.h could have a #if defined(__INT_FAST8_TYPE__) macro around the above devices to prevent such issues

context
-------

platform: x86_64/amd64
distribution: Linux Mint 17.1 Rebecca
newlib: 2.2.0+git20150830
gcc-arm-none-eabi: 4.9.3+svn231177

the newlib git source code has the same code: https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=newlib/libc/include/sys/_intsup.h;h=b979d5c4df5e4a224456cfc7631357ffcaac65f9;hb=HEAD
the only similar issue (but not the same) I found is here: https://sourceware.org/ml/newlib/2015/msg00551.html

Is the solution I proposed the right one, or am I missing something?

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

* Re: __INT_FAST*_TYPE__ undefined
  2016-08-21  9:41 __INT_FAST*_TYPE__ undefined Kévin
@ 2016-08-21 18:58 ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2016-08-21 18:58 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 2105 bytes --]

Hey Kevin,

On Aug 21 11:41, Kévin wrote:
> Hi,
> 
> I have an issue with compiling using newlib and stdint.
> 
> issue
> -----
> 
> when I compile against newlib I get the following error:
> 
> clang -target arm-none-eabi -Os -g -std=c99 -nostdlib -nostdinc -fno-common -ffunction-sections -fdata-sections -ffreestanding -Wpedantic -Wall -Werror -Wextra -Wundef -Wshadow -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes -Wstrict-overflow=5 -I/usr/include/newlib/ -I/usr/lib/gcc/arm-none-eabi/*/include/ -I. -mthumb -mcpu=cortex-m3 -o global.o -c global.c
> In file included from global.c:21:
> In file included from /usr/include/newlib/stdint.h:13:
> /usr/include/newlib/sys/_intsup.h:118:6: error: '__INT_FAST8_TYPE__' is not defined, evaluates to 0 [-Werror,-Wundef]
> #if (__INT_FAST8_TYPE__ == 0)
> ...
> 
> analysis
> --------
> 
> global.c:21 is the following
> #include <stdint.h> // standard integer types
> 
> I am not using the system library but newlib (-nostdlib -nostdinc -I/usr/include/newlib/)
> thus the stdint.h included is /usr/include/newlib/stdint.h
> 
> stdint.h has the following (unconditional) include:
> #include <sys/_intsup.h>
> 
> _intsup.h has the following defines:
> #if (__INT_FAST8_TYPE__ == 0)
> #define __FAST8 "hh"
> #elif (__INT_FAST8_TYPE__ == 1 || __INT_FAST8_TYPE__ == 3)
> #define __FAST8 "h"
> #elif (__INT_FAST8_TYPE__ == 2)
> #define __FAST8
> #elif (__INT_FAST8_TYPE__ == 4 || __INT_FAST8_TYPE__ == 6)
> #define __FAST8 "l"
> #elif (__INT_FAST8_TYPE__ == 8 || __INT_FAST8_TYPE__ == 10)
> #define __FAST8 "ll"
> #endif
> this applies to other _INT_FAST and _INT_LEAST
> 
> but __INT_FAST8_TYPE__ is not defined anywhere in newlib, thus clang complains because I am using (-Werror -Wundef).
> 
> solution
> --------
> 
> __INT_FAST8_TYPE__ might be defined in another library such but not in the ones I use/include.

__INT_FAST8_TYPE__ is a GCC builtin, and I'd expect that clang follows suit.
IMHO this is a bug in the compiler.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2016-08-21 18:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-21  9:41 __INT_FAST*_TYPE__ undefined Kévin
2016-08-21 18:58 ` Corinna Vinschen

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