DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] C++ 98/03 rte_cpuflags.h compilation broken
@ 2015-10-25 12:06 Marc Sune
  0 siblings, 0 replies; only message in thread
From: Marc Sune @ 2015-10-25 12:06 UTC (permalink / raw)
  To: dev

During the revision of an application I maintain that is currently using
DPDK v1.7.1 and about to port it to 2.1.0, I realised that 2.1.0rc4 and
above (at least) are broken when compiling applications without C++11
support:

In file included from
/home/marc/personal/xdpd/build/src/xdpd/drivers/gnu_linux_dpdk/../../../..//libs/dpdk/build/include/rte_cpuflags.h:46:0,
                 from
/home/marc/personal/xdpd/build/src/xdpd/drivers/gnu_linux_dpdk/../../../..//libs/dpdk/build/include/rte_spinlock.h:43,
                 from
../../../../../../../../../src/xdpd/drivers/gnu_linux_dpdk/src/hal-imp/openflow/openflow1x/../../../pipeline-imp/packet_inline.h:26,
                 from
../../../../../../../../../src/xdpd/drivers/gnu_linux_dpdk/src/hal-imp/openflow/openflow1x/../../../pipeline-imp/packet.h:14,
                 from
../../../../../../../../../src/xdpd/drivers/gnu_linux_dpdk/src/hal-imp/openflow/openflow1x/of1x_driver.cc:13:
/home/marc/personal/xdpd/build/src/xdpd/drivers/gnu_linux_dpdk/../../../..//libs/dpdk/build/include/generic/rte_cpuflags.h:53:6:
error: use of enum 'rte_cpu_flag_t' without previous declaration
 enum rte_cpu_flag_t __RTE_CPUFLAG_UNDERLYING_TYPE;
      ^
/home/marc/personal/xdpd/build/src/xdpd/drivers/gnu_linux_dpdk/../../../..//libs/dpdk/build/include/generic/rte_cpuflags.h:58:6:
error: use of enum 'cpu_register_t' without previous declaration
 enum cpu_register_t __RTE_REGISTER_UNDERLYING_TYPE;
      ^
/home/marc/personal/xdpd/build/src/xdpd/drivers/gnu_linux_dpdk/../../../..//libs/dpdk/build/include/generic/rte_cpuflags.h:107:31:
error: use of enum 'rte_cpu_flag_t' without previous declaration
 rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature);
                               ^
In file included from
/home/marc/personal/xdpd/build/src/xdpd/drivers/gnu_linux_dpdk/../../../..//libs/dpdk/build/include/rte_spinlock.h:43:0,
                 from
../../../../../../../../../src/xdpd/drivers/gnu_linux_dpdk/src/hal-imp/openflow/openflow1x/../../../pipeline-imp/packet_inline.h:26,
                 from
../../../../../../../../../src/xdpd/drivers/gnu_linux_dpdk/src/hal-imp/openflow/openflow1x/../../../pipeline-imp/packet.h:14,
                 from
../../../../../../../../../src/xdpd/drivers/gnu_linux_dpdk/src/hal-imp/openflow/openflow1x/of1x_driver.cc:13:
/home/marc/personal/xdpd/build/src/xdpd/drivers/gnu_linux_dpdk/../../../..//libs/dpdk/build/include/rte_cpuflags.h:
In function 'int rte_cpu_get_flag_enabled(rte_cpu_flag_t)':
/home/marc/personal/xdpd/build/src/xdpd/drivers/gnu_linux_dpdk/../../../..//libs/dpdk/build/include/rte_cpuflags.h:278:53:
error: conflicting declaration of C function 'int
rte_cpu_get_flag_enabled(rte_cpu_flag_t)'
 rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature)
                                                     ^
In file included from
/home/marc/personal/xdpd/build/src/xdpd/drivers/gnu_linux_dpdk/../../../..//libs/dpdk/build/include/rte_cpuflags.h:46:0,
                 from
/home/marc/personal/xdpd/build/src/xdpd/drivers/gnu_linux_dpdk/../../../..//libs/dpdk/build/include/rte_spinlock.h:43,
                 from
../../../../../../../../../src/xdpd/drivers/gnu_linux_dpdk/src/hal-imp/openflow/openflow1x/../../../pipeline-imp/packet_inline.h:26,
                 from
../../../../../../../../../src/xdpd/drivers/gnu_linux_dpdk/src/hal-imp/openflow/openflow1x/../../../pipeline-imp/packet.h:14,
                 from
../../../../../../../../../src/xdpd/drivers/gnu_linux_dpdk/src/hal-imp/openflow/openflow1x/of1x_driver.cc:13:
/home/marc/personal/xdpd/build/src/xdpd/drivers/gnu_linux_dpdk/../../../..//libs/dpdk/build/include/generic/rte_cpuflags.h:107:1:
note: previous declaration 'int rte_cpu_get_flag_enabled(int)'
 rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature);
 ^
/home/marc/personal/xdpd/build/src/xdpd/drivers/gnu_linux_dpdk/../../../..//libs/dpdk/build/include/generic/rte_cpuflags.h:
At global scope:
/home/marc/personal/xdpd/build/src/xdpd/drivers/gnu_linux_dpdk/../../../..//libs/dpdk/build/include/generic/rte_cpuflags.h:107:1:
error: 'int rte_cpu_get_flag_enabled(int)' declared 'static' but never
defined [-Werror=unused-function]

There was a commit from J. Kim:

commit 621389bbbe0860d41538aeac893b6d74e714530c
Author: Joongi Kim <joongi@an.kaist.ac.kr>
Date:   Fri Jul 3 21:51:03 2015 +0900

    eal: fix C++ app build

     * Forward declaration of enum in C++ requires explicit underlying
       type definitions.

     * This fixes the issue at:
       http://dpdk.org/ml/archives/dev/2015-April/017065.html

    include/generic/rte_cpuflags.h:50:6:
    error: use of enum ‘rte_cpu_flag_t’ without previous declaration
     enum rte_cpu_flag_t;

    include/generic/rte_cpuflags.h:55:6:
    error: use of enum ‘cpu_register_t’ without previous declaration
     enum cpu_register_t;

    Signed-off-by: Joongi Kim <joongi@an.kaist.ac.kr>
    [Thomas: fix extended to ppc and tile]


that partially addresses the compilation of rte_cpuflags.h in C++, but only
works for C++11 and above.

A solution could be to
make dpdk/lib/librte_eal/common/include/generic/rte_cpuflags.h
conditionally include the right arch dependent rte_cpuflags.h depending on
the rte_config.h ARCH variable, and move the prototype of this function
there, after the (real) enum decl:

101 /**

102  * Function for checking a CPU flag availability

103  *

104  * @param feature

105  *     CPU flag to query CPU for

106  * @return

107  *     1 if flag is available

108  *     0 if flag is not available

109  *     -ENOENT if flag is invalid

110  */

111 static inline int

112 rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature);

Converting rte_cpu_get_flag_enabled() argument into an int and typecast is
worse, IMHO.

Thoughts?
marc

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-10-25 12:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-25 12:06 [dpdk-dev] C++ 98/03 rte_cpuflags.h compilation broken Marc Sune

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).