Hi Masahiro, On 22 December 2014 at 03:16, Masahiro Yamada <[email protected]> wrote: > CONFIG_USE_STDINT was introduced to use compiler-provided types for > fixed-width variables. > This must be consistent everywhere to avoid warnings/errors > including printf() and friends. > > Assume the code below > > uint32_t foo; > > printf("foo= %x\n", foo); > > If <stdint.h> is included, uint32_t is defined by the compiler. > The code above only works on compilers that define "uint32_t" > as "unsigned int". Actually there exist compilers that define > "uint32_t" as "unsigned long". > > Going forward, to print out fixed-width variables, we always have > to use PRIxN like this > > uint32_t foo; > > printf("foo= " PRIx32 "\n", foo); > > Notice, > > - Typedefs ( uint32_t, int32_t etc.) are provided by <stdint.h> > - Printf formats ( PRIx32, PRId32 etc.) are provided by <inttypes.h> > > Also notice, it makes sense only when <stdint.h> and <inttypes.h> are > provided by > the same compiler. > ^^^^^^^^^^^^^^^^^^ > > Commit 4166ecb24 (Add some standard headers external code might need) added > hard-coded include/inttypes.h. > It provides hard-coded PRIx32 "x", but it does not make sense. > Some compiler's <stdint.h> define "uint32_t" as "unsigned long" > and expect the format string "lx" to print out "uint32_t" variable. > > This commit: > - Adds scripts/gcc-have-stdint.sh to check if the compiler is > providing both <stdint.h> and <inttypes.h> > > - Modifies config.mk to error-out if CONFIG_USE_STDINT is enabled, > but <stdint.h> or <inttyps.h> is missing > > - Modifies the top Makefile to delete "-nostdinc" option and allow to > include compiler-provided <inttypes.h> > > - Remove hard-coded include/inttypes.h
This patch looks good to me except that I don't understand why you are removing inttypes.h? Where will the PRI defines come from? Or is it because you are fixing things such that the defines are not needed anymore? > > Signed-off-by: Masahiro Yamada <[email protected]> > Cc: Gabe Black <[email protected]> > Cc: Simon Glass <[email protected]> > Cc: Bill Richardson <[email protected]> > Cc: Tom Rini <[email protected]> > --- > > Makefile | 2 +- > config.mk | 12 ++ > include/inttypes.h | 287 > --------------------------------------------- > scripts/gcc-have-stdint.sh | 21 ++++ > 4 files changed, 34 insertions(+), 288 deletions(-) > delete mode 100644 include/inttypes.h > create mode 100755 scripts/gcc-have-stdint.sh > [snip] Regards, Simon _______________________________________________ U-Boot mailing list [email protected] http://lists.denx.de/mailman/listinfo/u-boot

