From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adrien Mazarguil Subject: Re: Compilation errors in drivers/event/opdl/ Date: Fri, 26 Jan 2018 18:39:33 +0100 Message-ID: <20180126173933.GB4256@6wind.com> References: <20236883.VkVyGBRfOF@xps> <20180121093458.082f4589@xeon-e3> <5211400.X7DXXCoju3@xps> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: Stephen Hemminger , "Patil, Harish" , "liang.j.ma@intel.com" , "peter.mccarthy@intel.com" , jerin.jacob@caviumnetworks.com, dev@dpdk.org, ferruh.yigit@intel.com To: Thomas Monjalon Return-path: Received: from mail-wr0-f174.google.com (mail-wr0-f174.google.com [209.85.128.174]) by dpdk.org (Postfix) with ESMTP id 5FBF01B306 for ; Fri, 26 Jan 2018 18:39:46 +0100 (CET) Received: by mail-wr0-f174.google.com with SMTP id t16so1178003wrc.10 for ; Fri, 26 Jan 2018 09:39:46 -0800 (PST) Content-Disposition: inline In-Reply-To: <5211400.X7DXXCoju3@xps> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" (Replying since you added me to this thread) On Sun, Jan 21, 2018 at 06:49:13PM +0100, Thomas Monjalon wrote: > 21/01/2018 18:34, Stephen Hemminger: > > On Sat, 20 Jan 2018 09:44:46 +0100 > > Thomas Monjalon wrote: > > > > > 20/01/2018 06:18, Patil, Harish: > > > > Hi, > > > > > > > > I am seeing below compilation errors in drivers/event/opdl/, this is with > > > > cloned latest DPDK (git clone http://dpdk.org/git/dpdk). > > > > > > > > .. > > > > .. > > > > /home2/hpatil/e4/jan19-inbox-submit/dpdk/drivers/event/opdl/opdl_evdev_xsta > > > > ts.c: In function ‘opdl_xstats_get_names’: > > > > /home2/hpatil/e4/jan19-inbox-submit/dpdk/drivers/event/opdl/opdl_evdev_xsta > > > > ts.c:89:2: error: ‘for’ loop initial declarations are only allowed in > > > > C99 mode > > > > for (uint32_t j = 0; j < max_num_port_xstat; j++) { > > > > ^ > > > > > > My compiler does not raise this error. > > > What is your compiler? > > > > > > Anyone to fix it QUICKLY please? today? > > > > > > Harish, do you think we should revert if not fixed? > > > > Using declaration in for loop is a C++ thing which was inherited into C99. > > Does DPDK require C99 mode? > > No DPDK is not generally C99. Except we use enough C99isms (named initializers anyone?) that I think it's safe to say DPDK won't ever compile in C90 mode. > > > Putting loop variables in for() looks better, but the rest of DPDK > > doesn't use that style. > > C99 was forced for this driver as a quick fix. > > Either the coding style guideline is updated to C99, > or this driver must be adapted to the DPDK coding style. > I have no strong opinion. When -std is not specified, depending on its version GCC defaults either to gnu90, gnu99 or gnu11, all based on the C standard in question with a number of GNU extensions. Named initializers typically never fail because they're otherwise part of the GNU extensions. Others such as the "for" declaration above apparently aren't considered part of gnu90. > Is C99 well supported in all compilers we want to use (including Windows)? If by Windows you mean MSVC, from memory (likely outdated) it's actually a C++ compiler that only provides limited support for C99, this fact will trigger many other issues. The above loop won't be one of them though. On the GCC/clang side, -std=gnu99 is what we assume in DPDK today without explicitly documenting it. Exported headers conform a stricter standard, they are compatible with -std=c99 with GNU extensions explicitly tagged whenever they can't be worked around. -- Adrien Mazarguil 6WIND