<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 2, 2024 at 2:41 AM Bruce Richardson <<a href="mailto:bruce.richardson@intel.com">bruce.richardson@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, Feb 02, 2024 at 10:18:23AM +0100, Thomas Monjalon wrote:<br>
> 02/02/2024 06:13, Ashish Sadanandan:<br>
> > The header was missing the extern "C" directive which causes name<br>
> > mangling of functions by C++ compilers, leading to linker errors<br>
> > complaining of undefined references to these functions.<br>
> > <br>
> > Fixes: 86c743cf9140 ("eal: define generic vector types")<br>
> > Cc: <a href="mailto:nelio.laranjeiro@6wind.com" target="_blank">nelio.laranjeiro@6wind.com</a><br>
> > Cc: <a href="mailto:stable@dpdk.org" target="_blank">stable@dpdk.org</a><br>
> > <br>
> > Signed-off-by: Ashish Sadanandan <<a href="mailto:ashish.sadanandan@gmail.com" target="_blank">ashish.sadanandan@gmail.com</a>><br>
> <br>
> Thank you for improving C++ compatibility.<br>
> <br>
> I'm not sure what is best to fix it.<br>
> You are adding extern "C" in a file which is not directly included<br>
> by the user app. The same was done for rte_rwlock.h.<br>
> The other way is to make sure this include is in an extern "C" block<br>
> in lib/eal/*/include/rte_vect.h (instead of being before the block).<br>
> <br>
> I would like we use the same approach for all files.<br>
> Opinions?<br>
> <br>
I think just having the extern "C" guard in all files is the safest choice,<br>
because it's immediately obvious in each and every file that it is correct.<br>
Taking the other option, to check any indirect include file you need to go<br>
finding what other files include it and check there that a) they have<br>
include guards and b) the include for the indirect header is contained<br>
within it.<br>
<br>
Adopting the policy of putting the guard in each and every header is also a<br>
lot easier to do basic automated sanity checks on. If the file ends in .h,<br>
we just use grep to quickly verify it's not missing the guards. [Naturally,<br>
we can do more complete checks than that if we want, but 99% percent of<br>
misses can be picked up by a grep for the 'extern "C"' bit]<br>
<br>
/Bruce<br></blockquote><div><br></div><div>100% agree with Bruce. It's a valid ideological argument that private headers</div><div>don't need such safeguards, but it's difficult to enforce and easy to break<br>during refactoring.</div><div><br></div><div>- Ashish<br></div></div></div>