[dpdk-dev] [PATCH] eal: standard c++ forbids defining the keyword asm as a macro

Thomas Monjalon thomas at monjalon.net
Wed Mar 24 18:52:40 CET 2021


24/03/2021 18:28, Tyler Retzlaff:
> On Wed, Mar 24, 2021 at 06:04:08PM +0100, Thomas Monjalon wrote:
> > 24/03/2021 17:45, Tyler Retzlaff:
> > 
> > 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.
> 
> so to qualify. you mean maybe it is breaking compilation of c++ in a
> compiler that explicitly violates c++ standard when compiling c++? that
> would mean it is not a c++ compiler.

The asm keyword is part of all C++ standards?
It seems asm is non-standard in C,
that's why we use __asm__.

> in general i don't think it is a good practice to have dpdk introduce
> names into the application namespace unqualified, but the point you make
> is valid it can break c++ compilation if something was using this macro
> as a convenience to the compiler specific extension __asm__. there will
> be further issues with varying syntaxes that __asm__-style extensions
> take from compiler to compiler as well.

Yes we need to make sure there is no specific extension involved.
Is C++ asm the same as the C __asm__?

> would you prefer that i change the preprocessor protection to include only
> windows? since i'm certain that this will break for any c++ compiler on
> windows the moment any stl header is included.

No, C++ is probably the right scope.

> let me know how to adjust the patch i'll submit a new version.

I don't know yet. I would like to understand the global picture,
and have it properly documented in this commit log.





More information about the dev mailing list