From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 846788E91 for ; Wed, 4 Nov 2015 15:10:55 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP; 04 Nov 2015 06:10:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,243,1444719600"; d="scan'208";a="842947701" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.208.62]) by fmsmga002.fm.intel.com with SMTP; 04 Nov 2015 06:10:51 -0800 Received: by (sSMTP sendmail emulation); Wed, 04 Nov 2015 14:10:51 +0025 Date: Wed, 4 Nov 2015 14:10:50 +0000 From: Bruce Richardson To: Thomas Monjalon , dev@dpdk.org Message-ID: <20151104141050.GA19636@bricha3-MOBL3> References: <1441811374-28984-1-git-send-email-bruce.richardson@intel.com> <1446552059-5446-1-git-send-email-bruce.richardson@intel.com> <1446552059-5446-3-git-send-email-bruce.richardson@intel.com> <4698587.GS9blBozDC@xps13> <20151104102418.GN3518@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151104102418.GN3518@6wind.com> Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v3 2/4] ethdev: move error checking macros to header X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Nov 2015 14:10:55 -0000 On Wed, Nov 04, 2015 at 11:24:18AM +0100, Adrien Mazarguil wrote: > On Wed, Nov 04, 2015 at 02:19:36AM +0100, Thomas Monjalon wrote: > > 2015-11-03 12:00, Bruce Richardson: > > > Move the function ptr and port id checking macros to the header file, so > > > that they can be used in the static inline functions there. In doxygen > > > comments, mark them as for internal use only. > > [...] > > > +/** > > > + * @internal > > > + * Macro to print a message if in debugging mode > > > + */ > > > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG > > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...) \ > > > + RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args) > > > +#else > > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...) > > > +#endif > > > > It does not compile because Mellanox drivers are pedantic: > > > > In file included from /home/thomas/projects/dpdk/dpdk/drivers/net/mlx4/mlx4.c:78:0: > > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h: At top level: > > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h:933:38: error: ISO C does not permit named variadic macros [-Werror=variadic-macros] > > #define RTE_PMD_DEBUG_TRACE(fmt, args...) \ > > I suggest something like the following definitions as a pedantic-proof and > standard compliant method (one drawback being that it cannot be done with a > single macro), see PMD_DRV_LOG() in drivers/net/mlx5/mlx5_utils.h which also > automatically appends a line feed: > > #ifdef RTE_LIBRTE_ETHDEV_DEBUG > > #define STRIP(a, b) a > #define OPAREN ( > #define CPAREN ) > #define COMMA , > > #define RTE_PMD_DEBUG_TRACE(...) \ > RTE_PMD_DEBUG_TRACE_(__VA_ARGS__ STRIP OPAREN, CPAREN) > > #define RTE_PMD_DEBUG_TRACE_(fmt, ...) \ > RTE_PMD_DEBUG_TRACE__(fmt COMMA __func__, __VA_ARGS__) > > #define RTE_PMD_DEBUG_TRACE__(...) \ > RTE_LOG(ERR, PMD, "%s: " __VA_ARGS__) > > #else /* RTE_LIBRTE_ETHDEV_DEBUG */ > > #define RTE_PMD_DEBUG_TRACE(...) > > #endif /* RTE_LIBRTE_ETHDEV_DEBUG */ > > STRIP() and other helper macros are used to manage the dangling comma issue > when __VA_ARGS__ is empty as in the first call below: > > RTE_PMD_DEBUG_TRACE("foo\n"); > RTE_PMD_DEBUG_TRACE("foo %u\n", 42); > > -- > Adrien Mazarguil > 6WIND Is this really the best way around this? It looks like a lot more complicated than the original solution. Do we really need to support the -pedantic flag in our header files? /Bruce