eal: fix C++ build (struct member: virtual)
PATCH 1/1 eal: fix C++ build (struct member: virtual)
'virtual' is a keyword and can't be used if the code is to compile with C++ compilers.
If rte_devargs.h was included in C++ code, compilation with clang++ failed with an error. g++ did not fail, but only because of a bug that treats it as an anonymous struct with a decl-specifier which it ignores.
This simply renames the member to 'virt'.
--- lib/librte_eal/common/eal_common_dev.c | 4 ++-- lib/librte_eal/common/eal_common_devargs.c | 8 ++++---- lib/librte_eal/common/include/rte_devargs.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)
lib/librte_eal/common/eal_common_dev.c +2 -2
@@ -107,10 +107,10 @@ rte_eal_dev_init(void)if (devargs->type !=RTE_DEVTYPE_VIRTUAL )continue ; -if (rte_eal_vdev_init (devargs->virtual.drv_name, +if (rte_eal_vdev_init (devargs->virt.drv_name, devargs->args)) {RTE_LOG (ERR ,EAL ,"failed to initialize %s device\n" , - devargs->virtual.drv_name); + devargs->virt.drv_name);return -1 ; } }
lib/librte_eal/common/eal_common_devargs.c +4 -4
@@ -107,9 +107,9 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)break ;case RTE_DEVTYPE_VIRTUAL :/* save driver name */ - ret =snprintf (devargs->virtual.drv_name, -sizeof (devargs->virtual.drv_name),"%s" , buf); -if (ret <0 || ret >= (int )sizeof (devargs->virtual.drv_name)) + ret =snprintf (devargs->virt.drv_name, +sizeof (devargs->virt.drv_name),"%s" , buf); +if (ret <0 || ret >= (int )sizeof (devargs->virt.drv_name)) goto fail;break ;
@@ -169,7 +169,7 @@ rte_eal_devargs_dump(FILE *f) devargs->args); else if (devargs->type == RTE_DEVTYPE_VIRTUAL) fprintf(f, " VIRTUAL %s %s\n", - devargs->virtual.drv_name, + devargs->virt.drv_name, devargs->args); else fprintf(f, " UNKNOWN %s\n", devargs->args);
lib/librte_eal/common/include/rte_devargs.h +1 -1
@@ -86,7 +86,7 @@ struct rte_devargs {struct {/** Driver name. */ char drv_name[32 ]; - } virtual; + } virt; };/** Arguments string as given by user or "" for no argument. */ char *args;
Signature · 1 line
2.5.3
Quoted 11 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Christoph Gysin
Sent: Saturday, September 26, 2015 2:10 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH] eal: fix C++ build (struct member: virtual)'virtual' is a keyword and can't be used if the code is to compile with C++ compilers.
Quoted 7 lines
If
rte_devargs.hwas included in C++ code, compilation with clang++ failed with an error. g++ did not fail, but only because of a bug that treats it as an anonymous struct with a decl-specifier which it ignores.This simply renames the member to 'virt'.
---
David, Thomas, are you OK with this change? Thanks, Cristian