DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: Tyler Retzlaff <roretzla@linux.microsoft.com>
Cc: dev@dpdk.org, david.marchand@redhat.com,
	bruce.richardson@intel.com, stephen@networkplumber.org,
	drc@linux.vnet.ibm.com
Subject: Re: [dpdk-dev] [PATCH] eal: standard c++ forbids defining the keyword asm as a macro
Date: Wed, 24 Mar 2021 18:04:08 +0100	[thread overview]
Message-ID: <6578330.zVv2phWGOd@thomas> (raw)
In-Reply-To: <20210324164512.GB14991@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>

24/03/2021 17:45, Tyler Retzlaff:
> On Wed, Mar 24, 2021 at 09:30:58AM +0100, Thomas Monjalon wrote:
> > 24/03/2021 05:26, Tyler Retzlaff:
> > > +#ifndef __cplusplus
> > >  #ifndef asm
> > >  #define asm __asm__
> > >  #endif
> > > +#endif
> > 
> > It requires more explanations.
> > Which compilers do not define asm?
> > What happens with C++ if asm is undefined?
> 
> i guess the subject line on my commit didn't communicate this properly
> sorry.
> 
> asm is a keyword in both the C and C++ standards. for C++ the keyword is
> not permitted to be re-defined.
> 
> here is the relevant text from the standard, in particular item (2).
> 
>   17.6.4.3.1 Macro names [macro.names]
> 
>   1
>   A translation unit that includes a standard library header shall not
>   #define or #undef names declared in any standard library header.
> 
>   2
>   A translation unit shall not #define or #undef names lexically identical
>   to keywords, to the identifiers listed in Table 3, or to the attribute-tokens
>   described in 7.6.
> 
> so when including rte_common.h into a translation unit that is being
> compiled C++ the rte_common.h violates the standard by leaking the
> #define asm macro.
> 
> this problem appears as soon as you try to build a C++ based dpdk
> application with clang using windows C++ runtime and #include <list>.

I understood this part.

My question is more about the reason for having this define.
I think it is there because some compilers don't have asm keyword,
but have __asm__. And maybe that's the case for some C++ compilers.
If I'm right, this patch is breaking compilation with some
C++ compilers.



  reply	other threads:[~2021-03-24 17:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24  4:26 Tyler Retzlaff
2021-03-24  8:30 ` Thomas Monjalon
2021-03-24 16:45   ` Tyler Retzlaff
2021-03-24 17:04     ` Thomas Monjalon [this message]
2021-03-24 17:28       ` Tyler Retzlaff
2021-03-24 17:52         ` Thomas Monjalon
2021-03-24 19:52           ` Stephen Hemminger
2021-03-24 21:58             ` Tyler Retzlaff
2021-03-24 21:55           ` Tyler Retzlaff
2021-03-24 22:41             ` Dmitry Kozlyuk
2021-03-25  0:09               ` Tyler Retzlaff
2021-03-25  8:00                 ` Thomas Monjalon
2021-03-25 18:50                   ` Tyler Retzlaff
2021-04-13 13:10                     ` Thomas Monjalon
2021-04-13 13:35 ` Thomas Monjalon
2021-04-17  1:16   ` Tyler Retzlaff

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=6578330.zVv2phWGOd@thomas \
    --to=thomas@monjalon.net \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=drc@linux.vnet.ibm.com \
    --cc=roretzla@linux.microsoft.com \
    --cc=stephen@networkplumber.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).