eal: add C++ include guard in generic/rte_vect.h
PATCH 1/1 eal: add C++ include guard in generic/rte_vect.h
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.
--- .mailmap | 2 +- lib/eal/include/generic/rte_vect.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-)
.mailmap +1 -1
@@ -140,7 +140,7 @@ Ashijeet Acharya <[email protected]> Ashish Gupta <[email protected]> <[email protected]> <[email protected]> Ashish Jain <[email protected]> Ashish Paul <[email protected]> -Ashish Sadanandan <[email protected]> +Ashish Sadanandan <[email protected]> <[email protected]> Ashish Shah <[email protected]> Ashwin Sekhar T K <[email protected]> <[email protected]> Asim Jamshed <[email protected]>
lib/eal/include/generic/rte_vect.h +8 -0
@@ -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_ */
Signature · 1 line
2.31.1
02/02/2024 06:13, Ashish Sadanandan:
Quoted 9 lines
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.
Signed-off-by Ashish Sadanandan <[email protected]>
Thank you for improving C++ compatibility.
I'm not sure what is best to fix it.
You are adding extern "C" in a file which is not directly included by the user app. The same was done for rte_rwlock.h.
The other way is to make sure this include is in an extern "C" block in lib/eal/*/include/rte_vect.h (instead of being before the block).
I would like we use the same approach for all files. Opinions?
Quoted 13 lines · Thomas Monjalon
02/02/2024 06:13, Ashish Sadanandan:
Quoted 9 lines
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.
Signed-off-by Ashish Sadanandan <[email protected]>Thank you for improving C++ compatibility.
Quoted 9 lines
I'm not sure what is best to fix it.
You are adding extern "C" in a file which is not directly included by the user app. The same was done forrte_rwlock.h.
The other way is to make sure this include is in an extern "C" block inlib/eal/*/include/rte_vect.h(instead of being before the block).I would like we use the same approach for all files. Opinions?
I think just having the extern "C" guard in all files is the safest choice, because it's immediately obvious in each and every file that it is correct. Taking the other option, to check any indirect include file you need to go finding what other files include it and check there that a) they have include guards and b) the include for the indirect header is contained within it.
Adopting the policy of putting the guard in each and every header is also a lot easier to do basic automated sanity checks on. If the file ends in .h, we just use grep to quickly verify it's not missing the guards. [Naturally, we can do more complete checks than that if we want, but 99% percent of misses can be picked up by a grep for the 'extern "C"' bit]
/Bruce
Quoted 30 lines · Bruce Richardson
Quoted 13 lines · Thomas Monjalon
02/02/2024 06:13, Ashish Sadanandan:
Quoted 9 lines
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.
Signed-off-by Ashish Sadanandan <[email protected]>Thank you for improving C++ compatibility.
Quoted 9 lines
I'm not sure what is best to fix it.
You are adding extern "C" in a file which is not directly included by the user app. The same was done forrte_rwlock.h.
The other way is to make sure this include is in an extern "C" block inlib/eal/*/include/rte_vect.h(instead of being before the block).I would like we use the same approach for all files. Opinions?
I think just having the extern "C" guard in all files is the safest choice, because it's immediately obvious in each and every file that it is correct. Taking the other option, to check any indirect include file you need to go finding what other files include it and check there that a) they have include guards and b) the include for the indirect header is contained within it.
Quoted 8 lines
Adopting the policy of putting the guard in each and every header is also a lot easier to do basic automated sanity checks on. If the file ends in .h, we just use grep to quickly verify it's not missing the guards. [Naturally, we can do more complete checks than that if we want, but 99% percent of misses can be picked up by a grep for the 'extern "C"' bit]
/Bruce
100% agree with Bruce. It's a valid ideological argument that private headers
don't need such safeguards, but it's difficult to enforce and easy to break during refactoring.
- Ashish
Quoted 16 lines · On Fri, 2 Feb 2024 13:58:19 -0700 Ashish Sadanandan…
Quoted 7 lines
I think just having the extern "C" guard in all files is the safest choice, because it's immediately obvious in each and every file that it is correct. Taking the other option, to check any indirect include file you need to go finding what other files include it and check there that a) they have include guards and b) the include for the indirect header is contained within it.
Quoted 8 lines
Adopting the policy of putting the guard in each and every header is also a lot easier to do basic automated sanity checks on. If the file ends in .h, we just use grep to quickly verify it's not missing the guards. [Naturally, we can do more complete checks than that if we want, but 99% percent of misses can be picked up by a grep for the 'extern "C"' bit]
/Bruce
Quoted 6 lines
100% agree with Bruce. It's a valid ideological argument that private headers
don't need such safeguards, but it's difficult to enforce and easy to break during refactoring.- Ashish
But splashing this across all the internal driver headers is bad idea. It should only apply to header files that exported in final package.
Quoted 24 lines · Stephen Hemminger
Quoted 21 lines · On Fri, 2 Feb 2024 13:58:19 -0700 Ashish Sadanandan…
Quoted 7 lines
I think just having the extern "C" guard in all files is the safest choice, because it's immediately obvious in each and every file that it is correct. Taking the other option, to check any indirect include file you need to go finding what other files include it and check there that a) they have include guards and b) the include for the indirect header is contained within it.
Quoted 8 lines
Adopting the policy of putting the guard in each and every header is also a lot easier to do basic automated sanity checks on. If the file ends in .h, we just use grep to quickly verify it's not missing the guards. [Naturally, we can do more complete checks than that if we want, but 99% percent of misses can be picked up by a grep for the 'extern "C"' bit]
/Bruce
100% agree with Bruce. It's a valid ideological argument that private headers
don't need such safeguards, but it's difficult to enforce and easy to break during refactoring.
Quoted 4 lines
Quoted 1 line
- Ashish
But splashing this across all the internal driver headers is bad idea. It should only apply to header files that exported in final package.
while we don't provide api/abi stability promises for driver headers we do optionally install them with -Denable_driver_sdk=true.
the driver sdk allows drivers to be developed outside of the dpdk source tree, many such drivers are explicitly authored in C++ and are outside of the dpdk source tree because dpdk does not allow C++ drivers in tree.
Quoted 30 lines · Bruce Richardson
Quoted 13 lines · Thomas Monjalon
02/02/2024 06:13, Ashish Sadanandan:
Quoted 9 lines
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.
Signed-off-by Ashish Sadanandan <[email protected]>Thank you for improving C++ compatibility.
Quoted 9 lines
I'm not sure what is best to fix it.
You are adding extern "C" in a file which is not directly included by the user app. The same was done forrte_rwlock.h.
The other way is to make sure this include is in an extern "C" block inlib/eal/*/include/rte_vect.h(instead of being before the block).I would like we use the same approach for all files. Opinions?
I think just having the extern "C" guard in all files is the safest choice, because it's immediately obvious in each and every file that it is correct. Taking the other option, to check any indirect include file you need to go finding what other files include it and check there that a) they have include guards and b) the include for the indirect header is contained within it.
Quoted 5 lines
Adopting the policy of putting the guard in each and every header is also a lot easier to do basic automated sanity checks on. If the file ends in .h, we just use grep to quickly verify it's not missing the guards. [Naturally, we can do more complete checks than that if we want, but 99% percent of misses can be picked up by a grep for the 'extern "C"' bit]
so first, i agree with what you say here. but one downside i've seen is that non-public symbols may end up as extern "C".
i've also been unsatisfied with the inconsistency of either having includes in or outside of the guards.
a lot of dpdk headers follow this pattern.
// foo.h
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
...
but some dpdk headers follow this pattern.
// foo.h
#include <stdio.h>
#ifdef __cplusplus
extern "C"
#endif
...
standard C headers include the guards so don't need to be inside the extern "C" block. one minor annoyance with always including inside the block is we can't reliably provide a offer a C++-only header without doing extern "C++".
please bear in mind i do not mean to suggest implementing any dpdk in C++ with this comment, merely that there are advantages to occasionally offering C++-only header content to applications should we wever want to.
in some cases for harmony between C and C++ it may be easier to interoperate by supplying some basic C++-only headers, this may become more important as it there appears to be increasing divergance between the C and C++ standards and interoperability.
for full disclosure i do anticipate having to provide some small bits of header only C++ for msvc which is why this is top of my mind.
finally, i'll also note that we could again be explicit in our intent to declare what is extern "C" / exported by instead marking the declared names (functions and variables) themselves in a more precise manner.
i.e.
__rte_<lib>_export // extern "C" or __declspec(dllexport) extern "C" void some_public_symbol(void);
you'll recall we had a related discussion about symbol visibility here which is somewhat a similar problem to being solved to symbol naming. if we were defaulting visibility to hidden and using a single mechanism to guarantee extern "C" linkage and public visibility exposure we could catch all "missed" symbols for C++ without having to build as C++ and reference the symbols.
https://mails.dpdk.org/archives/dev/2024-January/285109.html
i still intend to put forward an RFC for the discussion resulting from that thread (just haven't had time yet).
Quoted 2 lines
/Bruce
Quoted 76 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Monday, 5 February 2024 18.37Quoted 10 lines · Bruce Richardson
Quoted 9 lines · Thomas Monjalon
02/02/2024 06:13, Ashish Sadanandan:
Quoted 8 lines
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.
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Signed-off-by Ashish Sadanandan <[email protected]>Thank you for improving C++ compatibility.
I'm not sure what is best to fix it.
You are adding extern "C" in a file which is not directly included by the user app. The same was done forrte_rwlock.h. The other way is to make sure this include is in an extern "C"block
Quoted 1 line
Quoted 1 line
in
lib/eal/*/include/rte_vect.h(instead of being before theblock).
Quoted 5 lines
Quoted 4 lines
I would like we use the same approach for all files. Opinions?
I think just having the extern "C" guard in all files is the safest
choice,
Quoted 1 line
because it's immediately obvious in each and every file that it is
correct.
Quoted 1 line
Taking the other option, to check any indirect include file you need
to go
Quoted 2 lines
finding what other files include it and check there that a) they have include guards and b) the include for the indirect header is
contained
Quoted 3 lines
within it.
Adopting the policy of putting the guard in each and every header is
also a
Quoted 1 line
lot easier to do basic automated sanity checks on. If the file ends
in .h,
Quoted 1 line
we just use grep to quickly verify it's not missing the guards.
[Naturally,
Quoted 1 line
we can do more complete checks than that if we want, but 99% percent
of
Quoted 1 line
misses can be picked up by a grep for the 'extern "C"' bit]
so first, i agree with what you say here. but one downside i've seen is that non-public symbols may end up as extern "C".
i've also been unsatisfied with the inconsistency of either having includes in or outside of the guards.
a lot of dpdk headers follow this pattern.
//
foo.h
#ifdef__cplusplus
extern "C" {
#endif#include <
stdio.h>...
but some dpdk headers follow this pattern.
//
foo.h
#include <stdio.h>#ifdef
__cplusplus
extern "C"
#endif
Quoted 6 lines
...
standard C headers include the guards so don't need to be inside the extern "C" block. one minor annoyance with always including inside the block is we can't reliably provide a offer a C++-only header without doing extern "C++".
I would say that the first of the two above patterns is not only annoying, it is incorrect.
A DPDK header file should not change the meaning of any other header files it includes.
And although the incorrectness currently only screws up any C++ in those header files, I still consider it a bug.
Quoted 33 lines
please bear in mind i do not mean to suggest implementing any dpdk in C++ with this comment, merely that there are advantages to occasionally offering C++-only header content to applications should we wever want to.
in some cases for harmony between C and C++ it may be easier to interoperate by supplying some basic C++-only headers, this may become more important as it there appears to be increasing divergance between the C and C++ standards and interoperability.
for full disclosure i do anticipate having to provide some small bits of
header only C++ for msvc which is why this is top of my mind.finally, i'll also note that we could again be explicit in our intent to
declare what is extern "C" / exported by instead marking the declared names
(functions and variables) themselves in a more precise manner.i.e.
__rte_<lib>_export // extern "C" or__declspec(dllexport)extern "C" voidsome_public_symbol(void);you'll recall we had a related discussion about symbol visibility here which is somewhat a similar problem to being solved to symbol naming. if
we were defaulting visibility to hidden and using a single mechanism to guarantee extern "C" linkage and public visibility exposure we could catch all "missed" symbols for C++ without having to build as C++ and reference the symbols.
Quoted 4 lines
https://mails.dpdk.org/archives/dev/2024-January/285109.html
i still intend to put forward an RFC for the discussion resulting from that thread (just haven't had time yet).
With that RFC, please also mention if function pointers need any special/additional considerations. No need to think about it yet. :-)
Quoted 3 lines
Quoted 3 lines
/Bruce
Quoted 78 lines · Morten Brørup
Quoted 78 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Monday, 5 February 2024 18.37Quoted 10 lines · Bruce Richardson
Quoted 9 lines · Thomas Monjalon
02/02/2024 06:13, Ashish Sadanandan:
Quoted 8 lines
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.
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Signed-off-by Ashish Sadanandan <[email protected]>Thank you for improving C++ compatibility.
I'm not sure what is best to fix it.
You are adding extern "C" in a file which is not directly included by the user app. The same was done forrte_rwlock.h. The other way is to make sure this include is in an extern "C"block
Quoted 1 line
Quoted 1 line
in
lib/eal/*/include/rte_vect.h(instead of being before theblock).
Quoted 5 lines
Quoted 4 lines
I would like we use the same approach for all files. Opinions?
I think just having the extern "C" guard in all files is the safest
choice,
Quoted 1 line
because it's immediately obvious in each and every file that it is
correct.
Quoted 1 line
Taking the other option, to check any indirect include file you need
to go
Quoted 2 lines
finding what other files include it and check there that a) they have include guards and b) the include for the indirect header is
contained
Quoted 3 lines
within it.
Adopting the policy of putting the guard in each and every header is
also a
Quoted 1 line
lot easier to do basic automated sanity checks on. If the file ends
in .h,
Quoted 1 line
we just use grep to quickly verify it's not missing the guards.
[Naturally,
Quoted 1 line
we can do more complete checks than that if we want, but 99% percent
of
Quoted 1 line
misses can be picked up by a grep for the 'extern "C"' bit]
so first, i agree with what you say here. but one downside i've seen is that non-public symbols may end up as extern "C".
i've also been unsatisfied with the inconsistency of either having includes in or outside of the guards.
a lot of dpdk headers follow this pattern.
//
foo.h
#ifdef__cplusplus
extern "C" {
#endif#include <
stdio.h>...
but some dpdk headers follow this pattern.
//
foo.h
#include <stdio.h>#ifdef
__cplusplus
extern "C"
#endif...
Quoted 9 lines
Quoted 4 lines
standard C headers include the guards so don't need to be inside the extern "C" block. one minor annoyance with always including inside the block is we can't reliably provide a offer a C++-only header without doing extern "C++".
I would say that the first of the two above patterns is not only annoying, it is incorrect.
A DPDK header file should not change the meaning of any other header files it includes.
And although the incorrectness currently only screws up any C++ in those header files, I still consider it a bug.
Should we document the proper extern "C" usage somewhere?
Quoted 93 lines
From: Ferruh Yigit [mailto:[email protected]]
Sent: Monday, 12 February 2024 16.43Quoted 26 lines · Morten Brørup
Quoted 26 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Monday, 5 February 2024 18.37Quoted 10 lines · Bruce Richardson
Quoted 9 lines · Thomas Monjalon
02/02/2024 06:13, Ashish Sadanandan:
Quoted 8 lines
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.
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Signed-off-by Ashish Sadanandan <[email protected]>Thank you for improving C++ compatibility.
I'm not sure what is best to fix it.
You are adding extern "C" in a file which is not directly included by the user app. The same was done forrte_rwlock.h. The other way is to make sure this include is in an extern "C"block
Quoted 1 line
Quoted 1 line
in
lib/eal/*/include/rte_vect.h(instead of being before theblock).
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
I would like we use the same approach for all files. Opinions?
I think just having the extern "C" guard in all files is the safest
choice,
Quoted 1 line
because it's immediately obvious in each and every file that it is
correct.
Quoted 1 line
Taking the other option, to check any indirect include file you
need
Quoted 2 lines
Quoted 2 lines
to go
Quoted 1 line
finding what other files include it and check there that a) they
have
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
include guards and b) the include for the indirect header is
contained
Quoted 3 lines
within it.
Adopting the policy of putting the guard in each and every header
is
Quoted 6 lines
Quoted 6 lines
also a
Quoted 1 line
lot easier to do basic automated sanity checks on. If the file ends
in .h,
Quoted 1 line
we just use grep to quickly verify it's not missing the guards.
[Naturally,
Quoted 1 line
we can do more complete checks than that if we want, but 99%
percent
Quoted 25 lines
Quoted 25 lines
of
Quoted 1 line
misses can be picked up by a grep for the 'extern "C"' bit]
so first, i agree with what you say here. but one downside i've seen is that non-public symbols may end up as extern "C".
i've also been unsatisfied with the inconsistency of either having includes in or outside of the guards.
a lot of dpdk headers follow this pattern.
//
foo.h
#ifdef__cplusplus
extern "C" {
#endif#include <
stdio.h>...
but some dpdk headers follow this pattern.
//
foo.h
#include <stdio.h>Quoted 8 lines
Quoted 8 lines
#ifdef
__cplusplus
extern "C"
#endif...
standard C headers include the guards so don't need to be inside the extern "C" block. one minor annoyance with always including inside
the
Quoted 4 lines
Quoted 2 lines
block is we can't reliably provide a offer a C++-only header without doing extern "C++".
I would say that the first of the two above patterns is not only
Quoted 8 lines
annoying, it is incorrect.
Quoted 1 line
A DPDK header file should not change the meaning of any other header
files it includes.
Quoted 1 line
And although the incorrectness currently only screws up any C++ in
those header files, I still consider it a bug.
Quoted 1 line
Should we document the proper extern "C" usage somewhere?
Good point!
It could be added to § 1.4.2. Header File Guards in the Coding Style chapter of the Contributor's Guidelines.
BTW, that paragraph (and its example) should be updated to reflect that alphabetical order is preferred.
Quoted 102 lines · Morten Brørup
Quoted 93 lines
From: Ferruh Yigit [mailto:[email protected]]
Sent: Monday, 12 February 2024 16.43Quoted 26 lines · Morten Brørup
Quoted 26 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Monday, 5 February 2024 18.37Quoted 10 lines · Bruce Richardson
Quoted 9 lines · Thomas Monjalon
02/02/2024 06:13, Ashish Sadanandan:
Quoted 8 lines
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.
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Signed-off-by Ashish Sadanandan <[email protected]>Thank you for improving C++ compatibility.
I'm not sure what is best to fix it.
You are adding extern "C" in a file which is not directly included by the user app. The same was done forrte_rwlock.h. The other way is to make sure this include is in an extern "C"block
Quoted 1 line
Quoted 1 line
in
lib/eal/*/include/rte_vect.h(instead of being before theblock).
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
I would like we use the same approach for all files. Opinions?
I think just having the extern "C" guard in all files is the safest
choice,
Quoted 1 line
because it's immediately obvious in each and every file that it is
correct.
Quoted 1 line
Taking the other option, to check any indirect include file you
need
Quoted 2 lines
Quoted 2 lines
to go
Quoted 1 line
finding what other files include it and check there that a) they
have
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
include guards and b) the include for the indirect header is
contained
Quoted 3 lines
within it.
Adopting the policy of putting the guard in each and every header
is
Quoted 6 lines
Quoted 6 lines
also a
Quoted 1 line
lot easier to do basic automated sanity checks on. If the file ends
in .h,
Quoted 1 line
we just use grep to quickly verify it's not missing the guards.
[Naturally,
Quoted 1 line
we can do more complete checks than that if we want, but 99%
percent
Quoted 25 lines
Quoted 25 lines
of
Quoted 1 line
misses can be picked up by a grep for the 'extern "C"' bit]
so first, i agree with what you say here. but one downside i've seen is that non-public symbols may end up as extern "C".
i've also been unsatisfied with the inconsistency of either having includes in or outside of the guards.
a lot of dpdk headers follow this pattern.
//
foo.h
#ifdef__cplusplus
extern "C" {
#endif#include <
stdio.h>...
but some dpdk headers follow this pattern.
//
foo.h
#include <stdio.h>Quoted 8 lines
Quoted 8 lines
#ifdef
__cplusplus
extern "C"
#endif...
standard C headers include the guards so don't need to be inside the extern "C" block. one minor annoyance with always including inside
the
Quoted 4 lines
Quoted 2 lines
block is we can't reliably provide a offer a C++-only header without doing extern "C++".
I would say that the first of the two above patterns is not only
Quoted 8 lines
annoying, it is incorrect.
Quoted 1 line
A DPDK header file should not change the meaning of any other header
files it includes.
Quoted 1 line
And although the incorrectness currently only screws up any C++ in
those header files, I still consider it a bug.
Quoted 1 line
Should we document the proper extern "C" usage somewhere?
Quoted 8 lines
Good point!
It could be added to § 1.4.2. Header File Guards in the Coding Style chapter of the Contributor's Guidelines.
BTW, that paragraph (and its example) should be updated to reflect that alphabetical order is preferred.
Was the intent of this comment that I should include this update in my patch? I'm happy to do it, but IMO the guideline update should be a separate commit.
It's been a month since the last activity on this thread, does someone need to sign off on this change before it can be merged?
Thanks,
Ashish
13/03/2024 21:26, Ashish Sadanandan:
Quoted 114 lines
Quoted 102 lines · Morten Brørup
Quoted 93 lines
From: Ferruh Yigit [mailto:[email protected]]
Sent: Monday, 12 February 2024 16.43Quoted 26 lines · Morten Brørup
Quoted 26 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Monday, 5 February 2024 18.37Quoted 10 lines · Bruce Richardson
Quoted 9 lines · Thomas Monjalon
02/02/2024 06:13, Ashish Sadanandan:
Quoted 8 lines
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.
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Signed-off-by Ashish Sadanandan <[email protected]>Thank you for improving C++ compatibility.
I'm not sure what is best to fix it.
You are adding extern "C" in a file which is not directly included by the user app. The same was done forrte_rwlock.h. The other way is to make sure this include is in an extern "C"block
Quoted 1 line
Quoted 1 line
in
lib/eal/*/include/rte_vect.h(instead of being before theblock).
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
I would like we use the same approach for all files. Opinions?
I think just having the extern "C" guard in all files is the safest
choice,
Quoted 1 line
because it's immediately obvious in each and every file that it is
correct.
Quoted 1 line
Taking the other option, to check any indirect include file you
need
Quoted 2 lines
Quoted 2 lines
to go
Quoted 1 line
finding what other files include it and check there that a) they
have
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
include guards and b) the include for the indirect header is
contained
Quoted 3 lines
within it.
Adopting the policy of putting the guard in each and every header
is
Quoted 6 lines
Quoted 6 lines
also a
Quoted 1 line
lot easier to do basic automated sanity checks on. If the file ends
in .h,
Quoted 1 line
we just use grep to quickly verify it's not missing the guards.
[Naturally,
Quoted 1 line
we can do more complete checks than that if we want, but 99%
percent
Quoted 25 lines
Quoted 25 lines
of
Quoted 1 line
misses can be picked up by a grep for the 'extern "C"' bit]
so first, i agree with what you say here. but one downside i've seen is that non-public symbols may end up as extern "C".
i've also been unsatisfied with the inconsistency of either having includes in or outside of the guards.
a lot of dpdk headers follow this pattern.
//
foo.h
#ifdef__cplusplus
extern "C" {
#endif#include <
stdio.h>...
but some dpdk headers follow this pattern.
//
foo.h
#include <stdio.h>Quoted 8 lines
Quoted 8 lines
#ifdef
__cplusplus
extern "C"
#endif...
standard C headers include the guards so don't need to be inside the extern "C" block. one minor annoyance with always including inside
the
Quoted 4 lines
Quoted 2 lines
block is we can't reliably provide a offer a C++-only header without doing extern "C++".
I would say that the first of the two above patterns is not only
Quoted 8 lines
annoying, it is incorrect.
Quoted 1 line
A DPDK header file should not change the meaning of any other header
files it includes.
Quoted 1 line
And although the incorrectness currently only screws up any C++ in
those header files, I still consider it a bug.
Quoted 1 line
Should we document the proper extern "C" usage somewhere?
Quoted 8 lines
Good point!
It could be added to § 1.4.2. Header File Guards in the Coding Style chapter of the Contributor's Guidelines.
BTW, that paragraph (and its example) should be updated to reflect that alphabetical order is preferred.
Quoted 6 lines
Was the intent of this comment that I should include this update in my patch? I'm happy to do it, but IMO the guideline update should be a separate commit.
It's been a month since the last activity on this thread, does someone need to sign off on this change before it can be merged?
Instead of doing one specific change, it would be better to change all files for consistency. So the guideline change can be in the same commit applying the new guideline.
Quoted 133 lines · Thomas Monjalon
13/03/2024 21:26, Ashish Sadanandan:
Quoted 6 lines
Quoted 3 lines · Morten Brørup
Quoted 3 lines
From: Ferruh Yigit [mailto:[email protected]]
Sent: Monday, 12 February 2024 16.43Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · Morten Brørup
Quoted 7 lines
Quoted 7 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Monday, 5 February 2024 18.37Quoted 3 lines · Bruce Richardson
Quoted 2 lines · Thomas Monjalon
02/02/2024 06:13, Ashish Sadanandan:
Quoted 1 line
The header was missing the extern "C" directive which causes
name
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
mangling of functions by C++ compilers, leading to linker
errors
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
complaining of undefined references to these functions.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Signed-off-by Ashish Sadanandan <[email protected]>Thank you for improving C++ compatibility.
I'm not sure what is best to fix it.
You are adding extern "C" in a file which is not directlyincluded
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines
by the user app. The same was done for
rte_rwlock.h. The other way is to make sure this include is in an extern "C"block
Quoted 1 line
Quoted 1 line
in
lib/eal/*/include/rte_vect.h(instead of being before theblock).
Quoted 5 lines
Quoted 4 lines
I would like we use the same approach for all files. Opinions?
I think just having the extern "C" guard in all files is the
safest
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
choice,
Quoted 1 line
because it's immediately obvious in each and every file that it
is
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
correct.
Quoted 1 line
Taking the other option, to check any indirect include file you
need
Quoted 2 lines
Quoted 2 lines
to go
Quoted 1 line
finding what other files include it and check there that a) they
have
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
include guards and b) the include for the indirect header is
contained
Quoted 3 lines
within it.
Adopting the policy of putting the guard in each and every header
is
Quoted 2 lines
Quoted 2 lines
also a
Quoted 1 line
lot easier to do basic automated sanity checks on. If the file
ends
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
in .h,
Quoted 1 line
we just use grep to quickly verify it's not missing the guards.
[Naturally,
Quoted 1 line
we can do more complete checks than that if we want, but 99%
percent
Quoted 4 lines
Quoted 4 lines
of
Quoted 1 line
misses can be picked up by a grep for the 'extern "C"' bit]
so first, i agree with what you say here. but one downside i've
seen
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
is that non-public symbols may end up as extern "C".
i've also been unsatisfied with the inconsistency of either having includes in or outside of the guards.
a lot of dpdk headers follow this pattern.
//
foo.h
#ifdef__cplusplus
extern "C" {
#endif#include <
stdio.h>...
but some dpdk headers follow this pattern.
//
foo.h
#include <stdio.h>Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
#ifdef
__cplusplus
extern "C"
#endif...
standard C headers include the guards so don't need to be inside
the
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
extern "C" block. one minor annoyance with always including inside
the
Quoted 1 line
Quoted 1 line
block is we can't reliably provide a offer a C++-only header
without
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
doing extern "C++".
I would say that the first of the two above patterns is not only
annoying, it is incorrect.
Quoted 1 line
A DPDK header file should not change the meaning of any other
header
Quoted 16 lines
Quoted 7 lines
Quoted 6 lines
files it includes.
Quoted 1 line
And although the incorrectness currently only screws up any C++ in
those header files, I still consider it a bug.
Quoted 1 line
Should we document the proper extern "C" usage somewhere?
Quoted 8 lines
Good point!
It could be added to § 1.4.2. Header File Guards in the Coding Style chapter of the Contributor's Guidelines.
BTW, that paragraph (and its example) should be updated to reflect that alphabetical order is preferred.
Quoted 5 lines
Was the intent of this comment that I should include this update in my patch? I'm happy to do it, but IMO the guideline update should be a separate commit.
It's been a month since the last activity on this thread, does someone
need
Quoted 1 line
to sign off on this change before it can be merged?
Quoted 7 lines
Instead of doing one specific change, it would be better to change all files for consistency.
So the guideline change can be in the same commit applying the new guideline.Fair enough, I'll take a crack at it tonight.
- Ashish
Quoted 23 lines · Bruce Richardson
Quoted 13 lines · Thomas Monjalon
02/02/2024 06:13, Ashish Sadanandan:
Quoted 9 lines
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.
Signed-off-by Ashish Sadanandan <[email protected]>Thank you for improving C++ compatibility.
Quoted 9 lines
I'm not sure what is best to fix it.
You are adding extern "C" in a file which is not directly included by the user app. The same was done forrte_rwlock.h.
The other way is to make sure this include is in an extern "C" block inlib/eal/*/include/rte_vect.h(instead of being before the block).I would like we use the same approach for all files. Opinions?
Quoted 7 lines
I think just having the extern "C" guard in all files is the safest choice, because it's immediately obvious in each and every file that it is correct. Taking the other option, to check any indirect include file you need to go finding what other files include it and check there that a) they have include guards and b) the include for the indirect header is contained within it.
I assume you mean all header files exposed to user (ones installed by meson), in that case +1
Quoted 7 lines
Adopting the policy of putting the guard in each and every header is also a lot easier to do basic automated sanity checks on. If the file ends in .h, we just use grep to quickly verify it's not missing the guards. [Naturally, we can do more complete checks than that if we want, but 99% percent of misses can be picked up by a grep for the 'extern "C"' bit]
/Bruce
PATCH v2 1/1 eal: add C++ include guard in generic/rte_vect.h
In reply to Ashish SadanandanThe 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.
--- .mailmap | 2 +- doc/guides/contributing/coding_style.rst | 21 +++++++++++++++++++++ lib/eal/include/generic/rte_vect.h | 8 ++++++++ 3 files changed, 30 insertions(+), 1 deletion(-)
.mailmap +1 -1
@@ -142,7 +142,7 @@ Ashijeet Acharya <[email protected]> Ashish Gupta <[email protected]> <[email protected]> <[email protected]> Ashish Jain <[email protected]> Ashish Paul <[email protected]> -Ashish Sadanandan <[email protected]> +Ashish Sadanandan <[email protected]> <[email protected]> Ashish Shah <[email protected]> Ashwin Sekhar T K <[email protected]> <[email protected]> Asim Jamshed <[email protected]>
doc/guides/contributing/coding_style.rst +21 -0
@@ -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 defintions 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 ~~~~~~
lib/eal/include/generic/rte_vect.h +8 -0
@@ -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_ */
Signature · 1 line
2.31.1
PATCH v3 1/1 eal: add C++ include guard in generic/rte_vect.h
In reply to Ashish SadanandanThe 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.
--- .mailmap | 2 +- doc/guides/contributing/coding_style.rst | 21 +++++++++++++++++++++ lib/eal/include/generic/rte_vect.h | 8 ++++++++ 3 files changed, 30 insertions(+), 1 deletion(-)
.mailmap +1 -1
@@ -142,7 +142,7 @@ Ashijeet Acharya <[email protected]> Ashish Gupta <[email protected]> <[email protected]> <[email protected]> Ashish Jain <[email protected]> Ashish Paul <[email protected]> -Ashish Sadanandan <[email protected]> +Ashish Sadanandan <[email protected]> <[email protected]> Ashish Shah <[email protected]> Ashwin Sekhar T K <[email protected]> <[email protected]> Asim Jamshed <[email protected]>
doc/guides/contributing/coding_style.rst +21 -0
@@ -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 ~~~~~~
lib/eal/include/generic/rte_vect.h +8 -0
@@ -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_ */
Signature · 1 line
2.31.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.
Quoted 100 lines · Ashish Sadanandan
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.Signed-off-by Ashish Sadanandan <[email protected]>--- .mailmap | 2 +- doc/guides/contributing/coding_style.rst | 21 +++++++++++++++++++++ lib/eal/include/generic/rte_vect.h | 8 ++++++++ 3 files changed, 30 insertions(+), 1 deletion(-).mailmap +0
-0@@ -142,7 +142,7 @@ Ashijeet Acharya <[email protected]> Ashish Gupta <[email protected]> <[email protected]> <[email protected]>
Ashish Jain <[email protected]>
Ashish Paul <[email protected]>.mailmap +1
-1-Ashish Sadanandan <[email protected]> +Ashish Sadanandan <[email protected]> <[email protected]>
Ashish Shah <[email protected]>
Ashwin Sekhar T K <[email protected]> <[email protected]Quoted 1 line
Asim Jamshed <[email protected]>
doc/guides/contributing/coding_style.rst +0
-0@@ -106,6 +106,27 @@ Headers should be protected against multipleinclusion with the usual:
#endif /* _FILE_H_ */doc/guides/contributing/coding_style.rst +4
-0+Language Linkage +~~~~~~~~~~~~~~~~ + +Public headers should enclose all function and variable declarations anddefinitions in an ``extern "C"`` block to facilitate interoperability with C++.
doc/guides/contributing/coding_style.rst +17
-0+ +.. code-block:: c + + #ifndef _FILE_H_ + #define _FILE_H_ + + #ifdef __cplusplus + extern "C" { + #endif + + /* Code */ + + #ifdef __cplusplus + } + #endif + + #endif /* _FILE_H_ */ Macros ~~~~~~lib/eal/include/generic/rte_vect.h +8
-1@@ -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
02/04/2024 18:03, Ashish Sadanandan:
Quoted 4 lines
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.
Quoted 39 lines
Quoted 36 lines · Ashish Sadanandan
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.Signed-off-by Ashish Sadanandan <[email protected]>--- .mailmap | 2 +- doc/guides/contributing/coding_style.rst | 21 +++++++++++++++++++++ lib/eal/include/generic/rte_vect.h | 8 ++++++++ 3 files changed, 30 insertions(+), 1 deletion(-)doc/guides/contributing/coding_style.rst +4
-0+Language Linkage +~~~~~~~~~~~~~~~~ + +Public headers should enclose all function and variable declarations anddefinitions in an ``extern "C"`` block to facilitate interoperability with C++.
doc/guides/contributing/coding_style.rst +9
-0+ +.. code-block:: c + + #ifndef _FILE_H_ + #define _FILE_H_ + + #ifdef __cplusplus + extern "C" { + #endif
Quoted 8 lines
doc/guides/contributing/coding_style.rst Headers should be protected against multiple inclusion with the usual: · line 129
Quoted 8 lines
doc/guides/contributing/coding_style.rst +8
-0+ + /* Code */ + + #ifdef __cplusplus + } + #endif + + #endif /* _FILE_H_ */
This is not describing where the includes should be placed.
Quoted 11 lines · Thomas Monjalon
02/04/2024 18:03, Ashish Sadanandan:
Quoted 2 lines
Hi everyone,
I've made the updates as suggested. Could someone please review thelatest
Quoted 2 lines
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?
Quoted 44 lines
Quoted 9 lines
Quoted 6 lines · Ashish Sadanandan
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 addedto
Quoted 13 lines
Quoted 13 lines
public headers.
Signed-off-by Ashish Sadanandan <[email protected]>--- .mailmap | 2 +- doc/guides/contributing/coding_style.rst | 21 +++++++++++++++++++++ lib/eal/include/generic/rte_vect.h | 8 ++++++++ 3 files changed, 30 insertions(+), 1 deletion(-)Quoted 6 lines
doc/guides/contributing/coding_style.rst Headers should be protected against multiple inclusion with the usual:
Quoted 6 lines
doc/guides/contributing/coding_style.rst +4
-0+Language Linkage +~~~~~~~~~~~~~~~~ + +Public headers should enclose all function and variable declarationsand
Quoted 1 line
Quoted 1 line
definitions in an ``extern "C"`` block to facilitate interoperability
with
Quoted 12 lines
Quoted 12 lines
C++.
doc/guides/contributing/coding_style.rst +11
-0+ +.. code-block:: c + + #ifndef _FILE_H_ + #define _FILE_H_ + + #ifdef __cplusplus + extern "C" { + #endif + + /* Code */
Quoted 9 lines
Quoted 6 lines
doc/guides/contributing/coding_style.rst Headers should be protected against multiple inclusion with the usual: · line 129
Quoted 6 lines
doc/guides/contributing/coding_style.rst +6
-0+ + #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.
Quoted 9 lines · On Sat, 6 Apr 2024 19:30:38 -0600 Ashish Sadanandan…
Quoted 7 lines · Thomas Monjalon
02/04/2024 18:03, Ashish Sadanandan:
Quoted 2 lines
Hi everyone,
I've made the updates as suggested. Could someone please review thelatest
Quoted 2 lines
patchset? Not sure if I followed the new patchset instructions correctly, I've always had trouble with that part.
Quoted 8 lines
Quoted 4 lines
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.
Quoted 13 lines · Ashish Sadanandan
On Wed, Apr 3, 2024 at 8:52 AM Thomas Monjalon <[email protected] <mailto:[email protected]>> 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.
Quoted 9 lines
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.
Quoted 61 lines
Quoted 3 lines
On Sun, Mar 17, 2024 at 8:44 PM Ashish Sadanandan < [email protected] <mailto:[email protected]>>
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: [email protected] <mailto:[email protected]> > > Cc: [email protected] <mailto:[email protected]> > > > > Signed-off-by: Ashish Sadanandan <[email protected] <mailto:[email protected]>> > > --- > > .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.
Quoted 31 lines · Ferruh Yigit
Quoted 13 lines · Ashish Sadanandan
On Wed, Apr 3, 2024 at 8:52 AM Thomas Monjalon <[email protected] <mailto:[email protected]>> 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.Quoted 9 lines
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.
Quoted 4 lines
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
Quoted 9 lines · Ashish Sadanandan
Quoted 7 lines · Thomas Monjalon
02/04/2024 18:03, Ashish Sadanandan:
Quoted 2 lines
Hi everyone,
I've made the updates as suggested. Could someone please review thelatest
Quoted 2 lines
patchset? Not sure if I followed the new patchset instructions correctly, I've always had trouble with that part.
Quoted 8 lines
Quoted 4 lines
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.
Quoted 60 lines
Quoted 46 lines
Quoted 11 lines
Quoted 6 lines · Ashish Sadanandan
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 addedto
Quoted 13 lines
Quoted 13 lines
public headers.
Signed-off-by Ashish Sadanandan <[email protected]>--- .mailmap | 2 +- doc/guides/contributing/coding_style.rst | 21 +++++++++++++++++++++ lib/eal/include/generic/rte_vect.h | 8 ++++++++ 3 files changed, 30 insertions(+), 1 deletion(-)Quoted 6 lines
doc/guides/contributing/coding_style.rst Headers should be protected against multiple inclusion with the usual:
Quoted 6 lines
doc/guides/contributing/coding_style.rst +4
-0+Language Linkage +~~~~~~~~~~~~~~~~ + +Public headers should enclose all function and variable declarationsand
Quoted 1 line
Quoted 1 line
definitions in an ``extern "C"`` block to facilitate interoperability
with
Quoted 12 lines
Quoted 12 lines
C++.
doc/guides/contributing/coding_style.rst +11
-0+ +.. code-block:: c + + #ifndef _FILE_H_ + #define _FILE_H_ + + #ifdef __cplusplus + extern "C" { + #endif + + /* Code */Quoted 9 lines
Quoted 6 lines
doc/guides/contributing/coding_style.rst Headers should be protected against multiple inclusion with the usual: · line 129
Quoted 6 lines
doc/guides/contributing/coding_style.rst +6
-0+ + #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.
Quoted 8 lines · Ashish Sadanandan
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.
Quoted 6 lines
Signed-off-by Ashish Sadanandan <[email protected]>---
Quoted 8 lines · Ashish Sadanandan
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.
Quoted 6 lines
Signed-off-by Ashish Sadanandan <[email protected]>---
Stephen Hemminger
Acked-byQuoted 9 lines · On Tue, 2 Apr 2024 09:19:23 -0700 Tyler Retzlaff…
Quoted 8 lines · Ashish Sadanandan
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.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Ashish Sadanandan <[email protected]>---
Acked-by Tyler Retzlaff <[email protected]>