From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH] mbuf: fix compile by making sched struct visible Date: Thu, 10 Jan 2019 14:05:11 -0800 Message-ID: <20190110140511.51728db0@hermes.lan> References: <20190110165051.4859-1-harry.van.haaren@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org, reshma.pattan@intel.com, cristian.dumitrescu@intel.com, thomas@monjalon.net To: Harry van Haaren Return-path: Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id E14861B738 for ; Thu, 10 Jan 2019 23:05:21 +0100 (CET) Received: by mail-pl1-f194.google.com with SMTP id gn14so5772258plb.10 for ; Thu, 10 Jan 2019 14:05:21 -0800 (PST) In-Reply-To: <20190110165051.4859-1-harry.van.haaren@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, 10 Jan 2019 16:50:51 +0000 Harry van Haaren wrote: > Although C compilation works with the struct rte_mbuf_sched > declared inside the struct rte_mbuf namespace, C++ fails to > compile. This fix moves the rte_mbuf_sched struct up to the > global namespace, instead of declaring it inside the struct > mbuf namespace. > > The struct rte_mbuf_sched is being used on the stack in > rte_mbuf_sched_get() and as a cast in _set(). For this > reason, it must be exposed as an available type. > > Fixes: 5d3f72100904 ("mbuf: implement generic format for sched field") > > Signed-off-by: Harry van Haaren > I believe this was done so that the compiler doesn't generate bad code. If you reference the mbuf to get the fields then each operation becomes a load shift and mask operation to get to the bitfield. But if they are local then this is all done on a single register value. Check the generated code. One solution would be to move this into a private header file where C++ won't find it.