From: Masahiro Yamada Date: Wed, 24 Dec 2014 17:44:03 +0900 Subject: [U-Boot] [PATCH 4/7] Check if compiler-provided and are available if CONFIG_USE_STDINT=y (MAD) In-Reply-To: References: <1419243363-11542-5-git-send-email-yamada.m@jp.panasonic.com> Message-ID: <20141224174402.1D4D.AA925319@jp.panasonic.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Simon, On Mon, 22 Dec 2014 21:46:26 -0700 Simon Glass wrote: > Hi Masahiro, > > On 22 December 2014 at 03:16, Masahiro Yamada 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 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 > > - Printf formats ( PRIx32, PRId32 etc.) are provided by > > > > Also notice, it makes sense only when and 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 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 and > > > > - Modifies config.mk to error-out if CONFIG_USE_STDINT is enabled, > > but or is missing > > > > - Modifies the top Makefile to delete "-nostdinc" option and allow to > > include compiler-provided > > > > - 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? According to this question, I am afraid you are not understanding very well. Maybe is this page useful? http://pubs.opengroup.org/onlinepubs/009695399/basedefs/inttypes.h.html My commit description has also answered your question: Notice, - Typedefs ( uint32_t, int32_t etc.) are provided by - Printf formats ( PRIx32, PRId32 etc.) are provided by Also notice, it makes sense only when and are provided by the same compiler. Best Regards Masahiro Yamada