All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: qian.q.xu@intel.com, dev@dpdk.org, hemant.agrawal@nxp.com,
	bruce.richardson@intel.com
Subject: Re: compilation error on Suse 11 - LPM init of anon union
Date: Mon, 15 Jan 2018 17:18:37 +0100	[thread overview]
Message-ID: <20180115161837.GY4256@6wind.com> (raw)
In-Reply-To: <13541534.8OkorCjPcv@xps>

On Sat, Jan 13, 2018 at 08:14:06PM +0100, Thomas Monjalon wrote:
> Hi,
> 
> There is a new compilation error since this commit in LPM:
> 	http://dpdk.org/commit/b2e1c99
> The brace has been removed because unnecessary with anonymous union.
> 
> This union is declared with RTE_STD_C11 for compatibility
> with old compilers:
> 	/** C extension macro for environments lacking C11 features. */
> 	#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
> 	#define RTE_STD_C11 __extension__                                                                    
> 	#else
> 	#define RTE_STD_C11
> 	#endif

Yes, however not only for old compilers, e.g. explicitly specifying -std=c99
on the command-line disables C11 extensions for newer compilers as well.

Not specifying anything (like most applications do) simply defaults to
whatever standard is deemed "current" for it.

In short, RTE_STD_C11 gets expanded as __extension__ when the compiler isn't
in C11 mode, and what follows is therefore an extension to the standard in
use (be it C90 or C99).

__extension__ remains explicitly used in place of RTE_STD_C11 for things
that are not even found in C11, namely GNU syntax extensions fall under this
category. Keep in mind the __extension__ keyword is itself a GNU extension.

> Unfortunately, it does not work on Suse 11 SP2 with GCC 4.5.1:
> 	lib/librte_lpm/rte_lpm.c: In function ‘add_depth_big_v20’:
> 	lib/librte_lpm/rte_lpm.c:886:4: error:
> 	unknown field ‘group_idx’ specified in initializer
> 
> Curiously, the error is exactly the same with ICC 16.0.2:
> 	http://dpdk.org/ml/archives/test-report/2018-January/038443.html
> Is it really using different compilers in those 2 tests?
> 
> Someone to check the value of __STDC_VERSION__ with those compilers?
> 	gcc -dM -E -xc /dev/null | grep STDC_VERSION
> 
> Thanks for the help

Since this problem only appears in big endian, my suggestion would be to add
RTE_STD_C11 to the anonymous union of struct rte_lpm_tbl_entry_v20
(rte_lpm.h), like its little endian counterpart:

 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
 [...]
         RTE_STD_C11
         union {
                 uint8_t next_hop;
                 uint8_t group_idx;
         };
 [...]
 #else
 __extension__
 struct rte_lpm_tbl_entry_v20 {
         uint8_t depth       :6;
         uint8_t valid_group :1;
         uint8_t valid       :1;
         RTE_STD_C11 // <<< Should be added here
         union {
                 uint8_t group_idx;
                 uint8_t next_hop;
         };
 };

I don't have the adequate test environment to validate this, so please
report if it helps and/or submit a patch, thanks.

-- 
Adrien Mazarguil
6WIND

  reply	other threads:[~2018-01-15 16:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-13 19:14 compilation error on Suse 11 - LPM init of anon union Thomas Monjalon
2018-01-15 16:18 ` Adrien Mazarguil [this message]
2018-01-15 17:08   ` Adrien Mazarguil
2018-01-17 22:49     ` Thomas Monjalon
2018-01-17 22:51       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180115161837.GY4256@6wind.com \
    --to=adrien.mazarguil@6wind.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=qian.q.xu@intel.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.