[v3,1/1] eal: add C++ include guard in generic/rte_vect.h

Message ID 20240318024415.555614-1-ashish.sadanandan@gmail.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series [v3,1/1] eal: add C++ include guard in generic/rte_vect.h |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Ashish Sadanandan March 18, 2024, 2:44 a.m. UTC
The header was missing the extern "C" directive which causes name
mangling of functions by C++ compilers, leading to linker errors
complaining of undefined references to these functions.

Also updated the coding style contribution guideline with a new
"Language Linkage" section stating `extern "C"` block should be added to
public headers.

Fixes: 86c743cf9140 ("eal: define generic vector types")
Cc: nelio.laranjeiro@6wind.com
Cc: stable@dpdk.org

Signed-off-by: Ashish Sadanandan <ashish.sadanandan@gmail.com>
---
 .mailmap                                 |  2 +-
 doc/guides/contributing/coding_style.rst | 21 +++++++++++++++++++++
 lib/eal/include/generic/rte_vect.h       |  8 ++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)
  

Comments

Ashish Sadanandan April 2, 2024, 4:03 p.m. UTC | #1
Hi everyone,
I've made the updates as suggested. Could someone please review the latest
patchset? Not sure if I followed the new patchset instructions correctly,
I've always had trouble with that part.

Thanks,
Ashish.

On Sun, Mar 17, 2024 at 8:44 PM Ashish Sadanandan <
ashish.sadanandan@gmail.com> wrote:

> The header was missing the extern "C" directive which causes name
> mangling of functions by C++ compilers, leading to linker errors
> complaining of undefined references to these functions.
>
> Also updated the coding style contribution guideline with a new
> "Language Linkage" section stating `extern "C"` block should be added to
> public headers.
>
> Fixes: 86c743cf9140 ("eal: define generic vector types")
> Cc: nelio.laranjeiro@6wind.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Ashish Sadanandan <ashish.sadanandan@gmail.com>
> ---
>  .mailmap                                 |  2 +-
>  doc/guides/contributing/coding_style.rst | 21 +++++++++++++++++++++
>  lib/eal/include/generic/rte_vect.h       |  8 ++++++++
>  3 files changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/.mailmap b/.mailmap
> index 50726e1232..24de59ba89 100644
> --- a/.mailmap
> +++ b/.mailmap
> @@ -142,7 +142,7 @@ Ashijeet Acharya <ashijeet.acharya@6wind.com>
>  Ashish Gupta <ashishg@marvell.com> <ashish.gupta@marvell.com> <
> ashish.gupta@caviumnetworks.com>
>  Ashish Jain <ashish.jain@nxp.com>
>  Ashish Paul <apaul@juniper.net>
> -Ashish Sadanandan <ashish.sadanandan@gmail.com>
> +Ashish Sadanandan <ashish.sadanandan@gmail.com> <
> quic_asadanan@quicinc.com>
>  Ashish Shah <ashish.n.shah@intel.com>
>  Ashwin Sekhar T K <asekhar@marvell.com> <ashwin.sekhar@caviumnetworks.com
> >
>  Asim Jamshed <asim.jamshed@gmail.com>
> diff --git a/doc/guides/contributing/coding_style.rst
> b/doc/guides/contributing/coding_style.rst
> index 1ebc79ca3c..27c947fcec 100644
> --- a/doc/guides/contributing/coding_style.rst
> +++ b/doc/guides/contributing/coding_style.rst
> @@ -106,6 +106,27 @@ Headers should be protected against multiple
> inclusion with the usual:
>
>     #endif /* _FILE_H_ */
>
> +Language Linkage
> +~~~~~~~~~~~~~~~~
> +
> +Public headers should enclose all function and variable declarations and
> definitions in an ``extern "C"`` block to facilitate interoperability with
> C++.
> +
> +.. code-block:: c
> +
> +   #ifndef _FILE_H_
> +   #define _FILE_H_
> +
> +   #ifdef __cplusplus
> +   extern "C" {
> +   #endif
> +
> +   /* Code */
> +
> +   #ifdef __cplusplus
> +   }
> +   #endif
> +
> +   #endif /* _FILE_H_ */
>
>  Macros
>  ~~~~~~
> diff --git a/lib/eal/include/generic/rte_vect.h
> b/lib/eal/include/generic/rte_vect.h
> index 6540419cd2..3578d8749b 100644
> --- a/lib/eal/include/generic/rte_vect.h
> +++ b/lib/eal/include/generic/rte_vect.h
> @@ -15,6 +15,10 @@
>
>  #include <stdint.h>
>
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
>  #ifndef RTE_TOOLCHAIN_MSVC
>
>  /* Unsigned vector types */
> @@ -226,4 +230,8 @@ uint16_t rte_vect_get_max_simd_bitwidth(void);
>   */
>  int rte_vect_set_max_simd_bitwidth(uint16_t bitwidth);
>
> +#ifdef __cplusplus
> +}
> +#endif
> +
>  #endif /* _RTE_VECT_H_ */
> --
> 2.31.1
>
>
  
Bruce Richardson April 2, 2024, 4:10 p.m. UTC | #2
On Sun, Mar 17, 2024 at 08:44:15PM -0600, Ashish Sadanandan wrote:
> The header was missing the extern "C" directive which causes name
> mangling of functions by C++ compilers, leading to linker errors
> complaining of undefined references to these functions.
> 
> Also updated the coding style contribution guideline with a new
> "Language Linkage" section stating `extern "C"` block should be added to
> public headers.
> 
> Fixes: 86c743cf9140 ("eal: define generic vector types")
> Cc: nelio.laranjeiro@6wind.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ashish Sadanandan <ashish.sadanandan@gmail.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  
Tyler Retzlaff April 2, 2024, 4:19 p.m. UTC | #3
On Sun, Mar 17, 2024 at 08:44:15PM -0600, Ashish Sadanandan wrote:
> The header was missing the extern "C" directive which causes name
> mangling of functions by C++ compilers, leading to linker errors
> complaining of undefined references to these functions.
> 
> Also updated the coding style contribution guideline with a new
> "Language Linkage" section stating `extern "C"` block should be added to
> public headers.
> 
> Fixes: 86c743cf9140 ("eal: define generic vector types")
> Cc: nelio.laranjeiro@6wind.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ashish Sadanandan <ashish.sadanandan@gmail.com>
> ---
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
  
Thomas Monjalon April 3, 2024, 2:52 p.m. UTC | #4
02/04/2024 18:03, Ashish Sadanandan:
> Hi everyone,
> I've made the updates as suggested. Could someone please review the latest
> patchset? Not sure if I followed the new patchset instructions correctly,
> I've always had trouble with that part.

I remember we were discussing about aligning all files.
I was waiting for a patch applying the rule we discussed.


> On Sun, Mar 17, 2024 at 8:44 PM Ashish Sadanandan <
> ashish.sadanandan@gmail.com> wrote:
> 
> > The header was missing the extern "C" directive which causes name
> > mangling of functions by C++ compilers, leading to linker errors
> > complaining of undefined references to these functions.
> >
> > Also updated the coding style contribution guideline with a new
> > "Language Linkage" section stating `extern "C"` block should be added to
> > public headers.
> >
> > Fixes: 86c743cf9140 ("eal: define generic vector types")
> > Cc: nelio.laranjeiro@6wind.com
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Ashish Sadanandan <ashish.sadanandan@gmail.com>
> > ---
> >  .mailmap                                 |  2 +-
> >  doc/guides/contributing/coding_style.rst | 21 +++++++++++++++++++++
> >  lib/eal/include/generic/rte_vect.h       |  8 ++++++++
> >  3 files changed, 30 insertions(+), 1 deletion(-)
> >
> > --- a/doc/guides/contributing/coding_style.rst
> > +++ b/doc/guides/contributing/coding_style.rst
> > +Language Linkage
> > +~~~~~~~~~~~~~~~~
> > +
> > +Public headers should enclose all function and variable declarations and
> > definitions in an ``extern "C"`` block to facilitate interoperability with
> > C++.
> > +
> > +.. code-block:: c
> > +
> > +   #ifndef _FILE_H_
> > +   #define _FILE_H_
> > +
> > +   #ifdef __cplusplus
> > +   extern "C" {
> > +   #endif
> > +
> > +   /* Code */
> > +
> > +   #ifdef __cplusplus
> > +   }
> > +   #endif
> > +
> > +   #endif /* _FILE_H_ */

This is not describing where the includes should be placed.
  
Ashish Sadanandan April 7, 2024, 1:30 a.m. UTC | #5
On Wed, Apr 3, 2024 at 8:52 AM Thomas Monjalon <thomas@monjalon.net> wrote:

> 02/04/2024 18:03, Ashish Sadanandan:
> > Hi everyone,
> > I've made the updates as suggested. Could someone please review the
> latest
> > patchset? Not sure if I followed the new patchset instructions correctly,
> > I've always had trouble with that part.
>
> I remember we were discussing about aligning all files.
> I was waiting for a patch applying the rule we discussed.
>
> I missed the part where people were volunteering me for additional work :)

The consensus seems to be that the extern "C" directives should only be in
public headers, not private ones. Can you please tell me if there's an easy
way to get a list of public headers?


> > On Sun, Mar 17, 2024 at 8:44 PM Ashish Sadanandan <
> > ashish.sadanandan@gmail.com> wrote:
> >
> > > The header was missing the extern "C" directive which causes name
> > > mangling of functions by C++ compilers, leading to linker errors
> > > complaining of undefined references to these functions.
> > >
> > > Also updated the coding style contribution guideline with a new
> > > "Language Linkage" section stating `extern "C"` block should be added
> to
> > > public headers.
> > >
> > > Fixes: 86c743cf9140 ("eal: define generic vector types")
> > > Cc: nelio.laranjeiro@6wind.com
> > > Cc: stable@dpdk.org
> > >
> > > Signed-off-by: Ashish Sadanandan <ashish.sadanandan@gmail.com>
> > > ---
> > >  .mailmap                                 |  2 +-
> > >  doc/guides/contributing/coding_style.rst | 21 +++++++++++++++++++++
> > >  lib/eal/include/generic/rte_vect.h       |  8 ++++++++
> > >  3 files changed, 30 insertions(+), 1 deletion(-)
> > >
> > > --- a/doc/guides/contributing/coding_style.rst
> > > +++ b/doc/guides/contributing/coding_style.rst
> > > +Language Linkage
> > > +~~~~~~~~~~~~~~~~
> > > +
> > > +Public headers should enclose all function and variable declarations
> and
> > > definitions in an ``extern "C"`` block to facilitate interoperability
> with
> > > C++.
> > > +
> > > +.. code-block:: c
> > > +
> > > +   #ifndef _FILE_H_
> > > +   #define _FILE_H_
> > > +
> > > +   #ifdef __cplusplus
> > > +   extern "C" {
> > > +   #endif
> > > +
> > > +   /* Code */
> > > +
> > > +   #ifdef __cplusplus
> > > +   }
> > > +   #endif
> > > +
> > > +   #endif /* _FILE_H_ */
>
> This is not describing where the includes should be placed.
>

Will address this along with the rest of the headers.

Regards,
Ashish.
  
Stephen Hemminger April 7, 2024, 5:04 p.m. UTC | #6
On Sat, 6 Apr 2024 19:30:38 -0600
Ashish Sadanandan <ashish.sadanandan@gmail.com> wrote:

> On Wed, Apr 3, 2024 at 8:52 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> 
> > 02/04/2024 18:03, Ashish Sadanandan:  
> > > Hi everyone,
> > > I've made the updates as suggested. Could someone please review the  
> > latest  
> > > patchset? Not sure if I followed the new patchset instructions correctly,
> > > I've always had trouble with that part.  
> >
> > I remember we were discussing about aligning all files.
> > I was waiting for a patch applying the rule we discussed.
> >
> > I missed the part where people were volunteering me for additional work :)  
> 
> The consensus seems to be that the extern "C" directives should only be in
> public headers, not private ones. Can you please tell me if there's an easy
> way to get a list of public headers?

The issue for private headers that Tyler mentioned is that MS has private
DPDK PMD's that are written in C++. Not sure if this needs to be considered
or supported.
  
Ferruh Yigit April 8, 2024, 8:50 a.m. UTC | #7
On 4/7/2024 2:30 AM, Ashish Sadanandan wrote:
> 
> 
> On Wed, Apr 3, 2024 at 8:52 AM Thomas Monjalon <thomas@monjalon.net
> <mailto:thomas@monjalon.net>> wrote:
> 
>     02/04/2024 18:03, Ashish Sadanandan:
>     > Hi everyone,
>     > I've made the updates as suggested. Could someone please review
>     the latest
>     > patchset? Not sure if I followed the new patchset instructions
>     correctly,
>     > I've always had trouble with that part.
> 
>     I remember we were discussing about aligning all files.
>     I was waiting for a patch applying the rule we discussed.
> 
> I missed the part where people were volunteering me for additional work :)
> 
> The consensus seems to be that the extern "C" directives should only be
> in public headers, not private ones. Can you please tell me if there's
> an easy way to get a list of public headers? 
> 

Public headers are installed as part of ninja install target, so one
option is you can install a build to a custom folder and get the list
from there.
Or they are listed in meson.build files in 'headers' variable, you can
parse them.


Don't get confused with 'driver_sdk_headers' variable in meson files,
that is the list of headers required for driver development, and
installed if sdk ('enable_driver_sdk') meson option is enabled.

> 
>     > On Sun, Mar 17, 2024 at 8:44 PM Ashish Sadanandan <
>     > ashish.sadanandan@gmail.com <mailto:ashish.sadanandan@gmail.com>>
>     wrote:
>     >
>     > > The header was missing the extern "C" directive which causes name
>     > > mangling of functions by C++ compilers, leading to linker errors
>     > > complaining of undefined references to these functions.
>     > >
>     > > Also updated the coding style contribution guideline with a new
>     > > "Language Linkage" section stating `extern "C"` block should be
>     added to
>     > > public headers.
>     > >
>     > > Fixes: 86c743cf9140 ("eal: define generic vector types")
>     > > Cc: nelio.laranjeiro@6wind.com <mailto:nelio.laranjeiro@6wind.com>
>     > > Cc: stable@dpdk.org <mailto:stable@dpdk.org>
>     > >
>     > > Signed-off-by: Ashish Sadanandan <ashish.sadanandan@gmail.com
>     <mailto:ashish.sadanandan@gmail.com>>
>     > > ---
>     > >  .mailmap                                 |  2 +-
>     > >  doc/guides/contributing/coding_style.rst | 21 +++++++++++++++++++++
>     > >  lib/eal/include/generic/rte_vect.h       |  8 ++++++++
>     > >  3 files changed, 30 insertions(+), 1 deletion(-)
>     > >
>     > > --- a/doc/guides/contributing/coding_style.rst
>     > > +++ b/doc/guides/contributing/coding_style.rst
>     > > +Language Linkage
>     > > +~~~~~~~~~~~~~~~~
>     > > +
>     > > +Public headers should enclose all function and variable
>     declarations and
>     > > definitions in an ``extern "C"`` block to facilitate
>     interoperability with
>     > > C++.
>     > > +
>     > > +.. code-block:: c
>     > > +
>     > > +   #ifndef _FILE_H_
>     > > +   #define _FILE_H_
>     > > +
>     > > +   #ifdef __cplusplus
>     > > +   extern "C" {
>     > > +   #endif
>     > > +
>     > > +   /* Code */
>     > > +
>     > > +   #ifdef __cplusplus
>     > > +   }
>     > > +   #endif
>     > > +
>     > > +   #endif /* _FILE_H_ */
> 
>     This is not describing where the includes should be placed.
>      
> 
> Will address this along with the rest of the headers.
> 
> Regards,
> Ashish.
  
Bruce Richardson April 8, 2024, 9:04 a.m. UTC | #8
On Mon, Apr 08, 2024 at 09:50:51AM +0100, Ferruh Yigit wrote:
> On 4/7/2024 2:30 AM, Ashish Sadanandan wrote:
> > 
> > 
> > On Wed, Apr 3, 2024 at 8:52 AM Thomas Monjalon <thomas@monjalon.net
> > <mailto:thomas@monjalon.net>> wrote:
> > 
> >     02/04/2024 18:03, Ashish Sadanandan:
> >     > Hi everyone,
> >     > I've made the updates as suggested. Could someone please review
> >     the latest
> >     > patchset? Not sure if I followed the new patchset instructions
> >     correctly,
> >     > I've always had trouble with that part.
> > 
> >     I remember we were discussing about aligning all files.
> >     I was waiting for a patch applying the rule we discussed.
> > 
> > I missed the part where people were volunteering me for additional work :)
> > 
> > The consensus seems to be that the extern "C" directives should only be
> > in public headers, not private ones. Can you please tell me if there's
> > an easy way to get a list of public headers? 
> > 
> 
> Public headers are installed as part of ninja install target, so one
> option is you can install a build to a custom folder and get the list
> from there.
> Or they are listed in meson.build files in 'headers' variable, you can
> parse them.
> 
> 
> Don't get confused with 'driver_sdk_headers' variable in meson files,
> that is the list of headers required for driver development, and
> installed if sdk ('enable_driver_sdk') meson option is enabled.
> 

I still don't see what the major issue is with just adding the guards to
all headers in DPDK. It would avoid any complications of which headers get
installed or when. They're stripped out on pre-processing, so it's not like
they are going to have a performance impact or anything.

/Bruce
  
Tyler Retzlaff April 8, 2024, 3:29 p.m. UTC | #9
On Sat, Apr 06, 2024 at 07:30:38PM -0600, Ashish Sadanandan wrote:
> On Wed, Apr 3, 2024 at 8:52 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> 
> > 02/04/2024 18:03, Ashish Sadanandan:
> > > Hi everyone,
> > > I've made the updates as suggested. Could someone please review the
> > latest
> > > patchset? Not sure if I followed the new patchset instructions correctly,
> > > I've always had trouble with that part.
> >
> > I remember we were discussing about aligning all files.
> > I was waiting for a patch applying the rule we discussed.
> >
> > I missed the part where people were volunteering me for additional work :)
> 
> The consensus seems to be that the extern "C" directives should only be in
> public headers, not private ones. Can you please tell me if there's an easy
> way to get a list of public headers?

build with driver_sdk_headers enabled.
run the meson install target.

all headers that are installed need the guard.

> 
> 
> > > On Sun, Mar 17, 2024 at 8:44 PM Ashish Sadanandan <
> > > ashish.sadanandan@gmail.com> wrote:
> > >
> > > > The header was missing the extern "C" directive which causes name
> > > > mangling of functions by C++ compilers, leading to linker errors
> > > > complaining of undefined references to these functions.
> > > >
> > > > Also updated the coding style contribution guideline with a new
> > > > "Language Linkage" section stating `extern "C"` block should be added
> > to
> > > > public headers.
> > > >
> > > > Fixes: 86c743cf9140 ("eal: define generic vector types")
> > > > Cc: nelio.laranjeiro@6wind.com
> > > > Cc: stable@dpdk.org
> > > >
> > > > Signed-off-by: Ashish Sadanandan <ashish.sadanandan@gmail.com>
> > > > ---
> > > >  .mailmap                                 |  2 +-
> > > >  doc/guides/contributing/coding_style.rst | 21 +++++++++++++++++++++
> > > >  lib/eal/include/generic/rte_vect.h       |  8 ++++++++
> > > >  3 files changed, 30 insertions(+), 1 deletion(-)
> > > >
> > > > --- a/doc/guides/contributing/coding_style.rst
> > > > +++ b/doc/guides/contributing/coding_style.rst
> > > > +Language Linkage
> > > > +~~~~~~~~~~~~~~~~
> > > > +
> > > > +Public headers should enclose all function and variable declarations
> > and
> > > > definitions in an ``extern "C"`` block to facilitate interoperability
> > with
> > > > C++.
> > > > +
> > > > +.. code-block:: c
> > > > +
> > > > +   #ifndef _FILE_H_
> > > > +   #define _FILE_H_
> > > > +
> > > > +   #ifdef __cplusplus
> > > > +   extern "C" {
> > > > +   #endif
> > > > +
> > > > +   /* Code */
> > > > +
> > > > +   #ifdef __cplusplus
> > > > +   }
> > > > +   #endif
> > > > +
> > > > +   #endif /* _FILE_H_ */
> >
> > This is not describing where the includes should be placed.
> >
> 
> Will address this along with the rest of the headers.
> 
> Regards,
> Ashish.
  
Stephen Hemminger Oct. 7, 2024, 8:20 p.m. UTC | #10
On Tue, 2 Apr 2024 09:19:23 -0700
Tyler Retzlaff <roretzla@linux.microsoft.com> wrote:

> On Sun, Mar 17, 2024 at 08:44:15PM -0600, Ashish Sadanandan wrote:
> > The header was missing the extern "C" directive which causes name
> > mangling of functions by C++ compilers, leading to linker errors
> > complaining of undefined references to these functions.
> > 
> > Also updated the coding style contribution guideline with a new
> > "Language Linkage" section stating `extern "C"` block should be added to
> > public headers.
> > 
> > Fixes: 86c743cf9140 ("eal: define generic vector types")
> > Cc: nelio.laranjeiro@6wind.com
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Ashish Sadanandan <ashish.sadanandan@gmail.com>
> > ---  
> Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> 

Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  

Patch

diff --git a/.mailmap b/.mailmap
index 50726e1232..24de59ba89 100644
--- a/.mailmap
+++ b/.mailmap
@@ -142,7 +142,7 @@  Ashijeet Acharya <ashijeet.acharya@6wind.com>
 Ashish Gupta <ashishg@marvell.com> <ashish.gupta@marvell.com> <ashish.gupta@caviumnetworks.com>
 Ashish Jain <ashish.jain@nxp.com>
 Ashish Paul <apaul@juniper.net>
-Ashish Sadanandan <ashish.sadanandan@gmail.com>
+Ashish Sadanandan <ashish.sadanandan@gmail.com> <quic_asadanan@quicinc.com>
 Ashish Shah <ashish.n.shah@intel.com>
 Ashwin Sekhar T K <asekhar@marvell.com> <ashwin.sekhar@caviumnetworks.com>
 Asim Jamshed <asim.jamshed@gmail.com>
diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
index 1ebc79ca3c..27c947fcec 100644
--- a/doc/guides/contributing/coding_style.rst
+++ b/doc/guides/contributing/coding_style.rst
@@ -106,6 +106,27 @@  Headers should be protected against multiple inclusion with the usual:
 
    #endif /* _FILE_H_ */
 
+Language Linkage
+~~~~~~~~~~~~~~~~
+
+Public headers should enclose all function and variable declarations and definitions in an ``extern "C"`` block to facilitate interoperability with C++.
+
+.. code-block:: c
+
+   #ifndef _FILE_H_
+   #define _FILE_H_
+
+   #ifdef __cplusplus
+   extern "C" {
+   #endif
+
+   /* Code */
+
+   #ifdef __cplusplus
+   }
+   #endif
+
+   #endif /* _FILE_H_ */
 
 Macros
 ~~~~~~
diff --git a/lib/eal/include/generic/rte_vect.h b/lib/eal/include/generic/rte_vect.h
index 6540419cd2..3578d8749b 100644
--- a/lib/eal/include/generic/rte_vect.h
+++ b/lib/eal/include/generic/rte_vect.h
@@ -15,6 +15,10 @@ 
 
 #include <stdint.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifndef RTE_TOOLCHAIN_MSVC
 
 /* Unsigned vector types */
@@ -226,4 +230,8 @@  uint16_t rte_vect_get_max_simd_bitwidth(void);
  */
 int rte_vect_set_max_simd_bitwidth(uint16_t bitwidth);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _RTE_VECT_H_ */