* [dpdk-dev] "virtual" C++ keyword used in rte_devargs.h and causes compilation error in C++ @ 2015-02-07 7:24 Ming Zhao 2015-02-07 20:23 ` Neil Horman 0 siblings, 1 reply; 5+ messages in thread From: Ming Zhao @ 2015-02-07 7:24 UTC (permalink / raw) To: dev The code is in rte_devargs.h: rte_devargs.h: /** Used if type is RTE_DEVTYPE_VIRTUAL. */ struct { /** Driver name. */ char drv_name[32]; } virtual; }; Which caused clang compiler to report error when this file is included by a cpp file, the error message is: In file included from net/dpdk/testing/base-test.cc:3: In file included from net/dpdk/testing/base-test.h:8: third-party/dpdk/lib/librte_eal/common/include/rte_devargs.h:89:5: error: 'virtual' can only appear on non-static member functions } virtual; ^ I think we should try to pick another name for this field. I would suggest calling it "vdev" instead, or I'll be happy to take another name if someone comes with a different idea. Thanks! Ming ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] "virtual" C++ keyword used in rte_devargs.h and causes compilation error in C++ 2015-02-07 7:24 [dpdk-dev] "virtual" C++ keyword used in rte_devargs.h and causes compilation error in C++ Ming Zhao @ 2015-02-07 20:23 ` Neil Horman 2015-02-08 6:33 ` Ming Zhao 0 siblings, 1 reply; 5+ messages in thread From: Neil Horman @ 2015-02-07 20:23 UTC (permalink / raw) To: Ming Zhao; +Cc: dev On Fri, Feb 06, 2015 at 11:24:15PM -0800, Ming Zhao wrote: > The code is in rte_devargs.h: > > rte_devargs.h: > > /** Used if type is RTE_DEVTYPE_VIRTUAL. */ > struct { > /** Driver name. */ > char drv_name[32]; > } virtual; > }; > > Which caused clang compiler to report error when this file is included > by a cpp file, the error message is: > > In file included from net/dpdk/testing/base-test.cc:3: > In file included from net/dpdk/testing/base-test.h:8: > third-party/dpdk/lib/librte_eal/common/include/rte_devargs.h:89:5: > error: 'virtual' can only appear on non-static > member functions > } virtual; > ^ > > I think we should try to pick another name for this field. I would > suggest calling it "vdev" instead, or I'll be happy to take another name > if someone comes with a different idea. > > Thanks! > Ming > You could do that, but it seems like it shouldn't be necessecary. Shouldn't the solution just be to encapsulate either the header file or the #include directive from the C++ file with extern C { }? Neil ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] "virtual" C++ keyword used in rte_devargs.h and causes compilation error in C++ 2015-02-07 20:23 ` Neil Horman @ 2015-02-08 6:33 ` Ming Zhao 2015-02-08 7:31 ` Ariel Rodriguez 0 siblings, 1 reply; 5+ messages in thread From: Ming Zhao @ 2015-02-08 6:33 UTC (permalink / raw) To: Neil Horman; +Cc: dev In fact the current rte_devargs.h header is enclosed inside extern C {} block already. But it looks like it's not sufficient. Also there is also the case that rte_devargs.virtual field could be accessed inside a cpp file. On 02/07/2015 12:23 PM, Neil Horman wrote: > On Fri, Feb 06, 2015 at 11:24:15PM -0800, Ming Zhao wrote: >> The code is in rte_devargs.h: >> >> rte_devargs.h: >> >> /** Used if type is RTE_DEVTYPE_VIRTUAL. */ >> struct { >> /** Driver name. */ >> char drv_name[32]; >> } virtual; >> }; >> >> Which caused clang compiler to report error when this file is included >> by a cpp file, the error message is: >> >> In file included from net/dpdk/testing/base-test.cc:3: >> In file included from net/dpdk/testing/base-test.h:8: >> third-party/dpdk/lib/librte_eal/common/include/rte_devargs.h:89:5: >> error: 'virtual' can only appear on non-static >> member functions >> } virtual; >> ^ >> >> I think we should try to pick another name for this field. I would >> suggest calling it "vdev" instead, or I'll be happy to take another name >> if someone comes with a different idea. >> >> Thanks! >> Ming >> > You could do that, but it seems like it shouldn't be necessecary. Shouldn't the > solution just be to encapsulate either the header file or the #include directive > from the C++ file with extern C { }? > Neil > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] "virtual" C++ keyword used in rte_devargs.h and causes compilation error in C++ 2015-02-08 6:33 ` Ming Zhao @ 2015-02-08 7:31 ` Ariel Rodriguez 2015-02-08 13:53 ` Neil Horman 0 siblings, 1 reply; 5+ messages in thread From: Ariel Rodriguez @ 2015-02-08 7:31 UTC (permalink / raw) To: Ming Zhao; +Cc: dev "virtual" is a reserved word in c++. When the c++ compiler "g++" use that header in a "extern way (just generate standard typo for function identifiers)", there`s not way that the compiler posible "turn off" the "virtual" reserved word. If, for example, you guys use the "new" word ... its just the same as virtual. Regards. On Sun, Feb 8, 2015 at 3:33 AM, Ming Zhao <mzhao@luminatewireless.com> wrote: > In fact the current rte_devargs.h header is enclosed inside extern C {} > block already. But it looks like it's not sufficient. Also there is also > the case that rte_devargs.virtual field could be accessed inside a cpp > file. > > On 02/07/2015 12:23 PM, Neil Horman wrote: > > On Fri, Feb 06, 2015 at 11:24:15PM -0800, Ming Zhao wrote: > >> The code is in rte_devargs.h: > >> > >> rte_devargs.h: > >> > >> /** Used if type is RTE_DEVTYPE_VIRTUAL. */ > >> struct { > >> /** Driver name. */ > >> char drv_name[32]; > >> } virtual; > >> }; > >> > >> Which caused clang compiler to report error when this file is included > >> by a cpp file, the error message is: > >> > >> In file included from net/dpdk/testing/base-test.cc:3: > >> In file included from net/dpdk/testing/base-test.h:8: > >> third-party/dpdk/lib/librte_eal/common/include/rte_devargs.h:89:5: > >> error: 'virtual' can only appear on non-static > >> member functions > >> } virtual; > >> ^ > >> > >> I think we should try to pick another name for this field. I would > >> suggest calling it "vdev" instead, or I'll be happy to take another name > >> if someone comes with a different idea. > >> > >> Thanks! > >> Ming > >> > > You could do that, but it seems like it shouldn't be necessecary. > Shouldn't the > > solution just be to encapsulate either the header file or the #include > directive > > from the C++ file with extern C { }? > > Neil > > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] "virtual" C++ keyword used in rte_devargs.h and causes compilation error in C++ 2015-02-08 7:31 ` Ariel Rodriguez @ 2015-02-08 13:53 ` Neil Horman 0 siblings, 0 replies; 5+ messages in thread From: Neil Horman @ 2015-02-08 13:53 UTC (permalink / raw) To: Ariel Rodriguez; +Cc: dev On Sun, Feb 08, 2015 at 04:31:39AM -0300, Ariel Rodriguez wrote: > "virtual" is a reserved word in c++. When the c++ compiler "g++" use that > header in a "extern way (just generate standard typo for function > identifiers)", there`s not way that the compiler posible "turn off" the > "virtual" reserved word. If, for example, you guys use the "new" word ... > its just the same as virtual. > Hmm, you're right, it seems the C++ specification only uses the extern "Language" construct to define linkage behavior, it in no way defines keyword recognition or behavior. Truthfully, while this would be easy to fix by just changing the name, it might be a good oportunity to make the rte_devargs struct private. It really doesn't need to be public at all, if you had an accessor/iterator function for the list, and that would implicitly solve the problem by moving all the identifiers out of any publically accessible namespace Neil > Regards. > > On Sun, Feb 8, 2015 at 3:33 AM, Ming Zhao <mzhao@luminatewireless.com> > wrote: > > > In fact the current rte_devargs.h header is enclosed inside extern C {} > > block already. But it looks like it's not sufficient. Also there is also > > the case that rte_devargs.virtual field could be accessed inside a cpp > > file. > > > > On 02/07/2015 12:23 PM, Neil Horman wrote: > > > On Fri, Feb 06, 2015 at 11:24:15PM -0800, Ming Zhao wrote: > > >> The code is in rte_devargs.h: > > >> > > >> rte_devargs.h: > > >> > > >> /** Used if type is RTE_DEVTYPE_VIRTUAL. */ > > >> struct { > > >> /** Driver name. */ > > >> char drv_name[32]; > > >> } virtual; > > >> }; > > >> > > >> Which caused clang compiler to report error when this file is included > > >> by a cpp file, the error message is: > > >> > > >> In file included from net/dpdk/testing/base-test.cc:3: > > >> In file included from net/dpdk/testing/base-test.h:8: > > >> third-party/dpdk/lib/librte_eal/common/include/rte_devargs.h:89:5: > > >> error: 'virtual' can only appear on non-static > > >> member functions > > >> } virtual; > > >> ^ > > >> > > >> I think we should try to pick another name for this field. I would > > >> suggest calling it "vdev" instead, or I'll be happy to take another name > > >> if someone comes with a different idea. > > >> > > >> Thanks! > > >> Ming > > >> > > > You could do that, but it seems like it shouldn't be necessecary. > > Shouldn't the > > > solution just be to encapsulate either the header file or the #include > > directive > > > from the C++ file with extern C { }? > > > Neil > > > > > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-02-08 13:53 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-02-07 7:24 [dpdk-dev] "virtual" C++ keyword used in rte_devargs.h and causes compilation error in C++ Ming Zhao 2015-02-07 20:23 ` Neil Horman 2015-02-08 6:33 ` Ming Zhao 2015-02-08 7:31 ` Ariel Rodriguez 2015-02-08 13:53 ` Neil Horman
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).