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]

__INT_FAST*_TYPE__ undefined


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?


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