[dpdk-dev] [PATCH] eal: standard c++ forbids defining the keyword asm as a macro
Tyler Retzlaff
roretzla at linux.microsoft.com
Sat Apr 17 03:16:05 CEST 2021
On Tue, Apr 13, 2021 at 03:35:53PM +0200, Thomas Monjalon wrote:
> 24/03/2021 05:26, Tyler Retzlaff:
> > --- a/lib/librte_eal/include/rte_common.h
> > +++ b/lib/librte_eal/include/rte_common.h
> > @@ -31,9 +31,11 @@ extern "C" {
> > #define typeof __typeof__
> > #endif
> >
> > +#ifndef __cplusplus
> > #ifndef asm
> > #define asm __asm__
> > #endif
> > +#endif
>
> Applied with this explanation:
>
> eal: do not redefine asm keyword in C++
>
> C++ forbids redefining a keyword as a macro.
> The keyword asm is conditionally-supported and implementation defined,
> but it seems our best guess.
>
> In C, if asm does not exist, it is defined as __asm__
> which is a GNU extension.
>
>
> One more question:
> Can we have a similar issue with typeof?
> I guess it works because typeof is not a keyword?
typeof isn't a keyword though don't fully understand the benefit of
#define typeof __typeof__ since it just pollutes the application
namespace. extensions and intrinsics generally should stay in the
namespace reserved for use by the compiler `__'.
i would say we will have a similar issue with any keyword defined in the
c++ standard if we are defining any of them.
More information about the dev
mailing list