27/02/2020 05:25, Dmitry Kozlyuk: > When using __attribute__((format(...)) on functions, GCC on Windows > assumes MS-specific format string by default, even if the underlying > stdio implementation is ANSI-compliant (either MS Unicersal CRT > or MinGW implementation). Wrap attribute into a macro that forces > GNU-specific format string when using GCC. > > Use this new attribute for logging and panic messages in EAL > and for output strings in cmdline library. > > Signed-off-by: Dmitry Kozlyuk <dmitry.kozl...@gmail.com> > --- > +/** > + * Check format string and its arguments at compile-time. > + * > + * GCC on Windows assumes MS-specific format string by default, > + * even if the underlying stdio implementation is ANSI-compliant, > + * so this must be overridden. > + */ > +#if defined(RTE_TOOLCHAIN_GCC) > +#define __rte_format_printf(format_index, first_arg) \ > + __attribute__((format(gnu_printf, format_index, first_arg))) > +#else > +#define __rte_format_printf(format_index, first_arg) \ > + __attribute__((format(printf, format_index, first_arg))) > +#endif
It does not work when compiling pmdinfogen with clang and drivers with gcc. I suggest this change (I can send a patch fixing the issue in other .h files): +/* + * RTE_TOOLCHAIN_GCC is true if the target is built with GCC, + * while a host application (like pmdinfogen) may have another compiler. + * RTE_CC_IS_GNU is true if the file is compiled with GCC, + * no matter it is a target or host application. + */ +#if defined __GNUC__ && !defined __clang__ && !defined __INTEL_COMPILER +#define RTE_CC_IS_GNU +#endif + +#ifdef RTE_CC_IS_GNU -/** Define GCC_VERSION **/ -#ifdef RTE_TOOLCHAIN_GCC #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + \ __GNUC_PATCHLEVEL__) #endif @@ -96,7 +105,7 @@ typedef uint16_t unaligned_uint16_t; * even if the underlying stdio implementation is ANSI-compliant, * so this must be overridden. */ -#if defined(RTE_TOOLCHAIN_GCC) +#ifdef RTE_CC_IS_GNU #define __rte_format_printf(format_index, first_arg) \ __attribute__((format(gnu_printf, format_index, first_arg))) #else