On Tue, Nov 10, 2015 at 06:12:28PM +0100, Adrien Mazarguil wrote: > On Tue, Nov 10, 2015 at 04:21:10PM +0000, Richardson, Bruce wrote: > > > > > > > -----Original Message----- > > > From: Adrien Mazarguil [mailto:adrien.mazarguil at 6wind.com] > > > Sent: Tuesday, November 10, 2015 4:08 PM > > > To: Richardson, Bruce <bruce.richardson at intel.com> > > > Cc: Stephen Hemminger <stephen at networkplumber.org>; Thomas Monjalon > > > <thomas.monjalon at 6wind.com>; dev at dpdk.org > > > Subject: Re: [dpdk-dev] [PATCH v3 2/4] ethdev: move error checking macros > > > to header > > > > > > On Mon, Nov 09, 2015 at 02:02:28PM +0000, Richardson, Bruce wrote: > > > [...] > > > > > From: Adrien Mazarguil [mailto:adrien.mazarguil at 6wind.com] > > > [...] > > > > > Untested but I guess modifying that function accordingly would look > > > like: > > > > > > > > > > static inline void > > > > > rte_pmd_debug_trace(const char *func_name, const char *fmt, ...) { > > > > > va_list ap; > > > > > va_start(ap, fmt); > > > > > > > > > > static __thread char buffer[vsnprintf(NULL, 0, fmt, ap)]; > > > > > > > > > > va_end(ap); > > > > > va_start(ap, fmt); > > > > > vsnprintf(buffer, sizeof(buffer), fmt, ap); > > > > > va_end(ap); > > > > > rte_log(RTE_LOG_ERR, RTE_LOGTYPE_PMD, "%s: %s", func_name, > > > > > buffer); } > > > > > > > > > > > > > Looks a much better option. > > > > > > > > From this, though, I assume then that we are only looking to support the > > > -pedantic flag in conjuction with c99 mode or above. Supporting -pedantic > > > with the pre-gcc-5 versions won't allow that to work though, as variably > > > sized arrays only came in with c99, and were gnu extensions before that. > > > > > > Right, -pedantic must follow a given standard such as -std=gnu99 otherwise > > > it's meaningless. > > > > > > However pre-GCC 5 is fine for most if not all features we use, see: > > > > > > https://gcc.gnu.org/c99status.html > > > > > > Mixed code and declarations are supported since GCC 3.0, __VA_ARGS__ in > > > macros since GCC 2.95 and variable length arrays since GCC 0.9, so as long > > > as we use a version that implements -std=gnu99 (or -std=c99 to be really > > > pedantic), it's fine. > > > > > > Besides DPDK already uses C99 extensively, even a few C11 features (such > > > as > > > embedded anonymous struct definitions) currently supported in C99 mode as > > > compiler extensions. I think we can safely ignore compilers that don't > > > support common C99 features. > > > > > > -- > > > Adrien Mazarguil > > > 6WIND > > > > Actually my point was slightly different. > > If we are supporting "-pedantic" in header files because "we don't know > > what compiler flags users are going to pass when", then we need to support > > it in C90 mode to do the job properly. If you take gcc 4.8 and compile some > > code with "-pedantic" as the only C-flag you are going to get lots of > > errors because it will default to C90 mode with pedantic, which means no > > varargs macros at all. > > Agreed, exported headers should actually be C90 compliant for these reasons > but C99 would be a start. I didn't know GCC 5 switched to C99 by default > (don't worry, I do not intend to go back to C90). > Actually, it's even better than C99, the default is now C11 (or gnu11 to be pedantic about it :-) )
https://gcc.gnu.org/gcc-5/changes.html Top line item is: "The default mode for C is now -std=gnu11 instead of -std=gnu89" I believe clang is making a similar change to a c11-based default. \o/ /Bruce

