DPDK patches and discussions
 help / color / mirror / Atom feed
From: Marc Sune <marcdevel@gmail.com>
To: dev@dpdk.org
Subject: [dpdk-dev] C++ 98/03 rte_cpuflags.h compilation broken
Date: Sun, 25 Oct 2015 13:06:54 +0100	[thread overview]
Message-ID: <CA+3n-TqPsGPASNp2f2tsh-S3JQkh3goZSZ5kEKqMFvtDB2nfLQ@mail.gmail.com> (raw)

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

                 reply	other threads:[~2015-10-25 12:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+3n-TqPsGPASNp2f2tsh-S3JQkh3goZSZ5kEKqMFvtDB2nfLQ@mail.gmail.com \
    --to=marcdevel@gmail.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).