On Sun, Feb 06, 2022 at 08:44:08AM +0800, Weiguo Li wrote: > To make C header file compatible with C++ linking, a conventional > practice enclose the code with braces as below: > > #ifdef __cplusplus extern "C" { #endif > > ... > > #ifdef __cplusplus } #endif > > Some alternative forms of "#ifdef __cplusplus", like "#if > defined(__cplusplus)" or "# ifdef __cplusplus", also work. > > While it's suspicious when a header file matchs this regular expression > "if.*__cplusplus" exactly once. > > The following script is used to find these files: grep -r ~/git/dpdk > --include=*.h -e "if.*__cplusplus" -c|grep ":1$" > > Apart from two false positive cases, I found some real issues -- some > missing the left brace parts, the others missing the right brace parts. > > In one of the cases, the c++ guard is removed since it's useless in > private header as previous patch (http://dpdk.org/patch/98948) noted. > For the other cases, the missing parts are supplemented. > Any headers that have filenames not starting with "rte_" are internal headers, and so should have the guards removed. Therefore, I think that most patches in this set should just be removing guards. From my tests with building our public headers in C++ files, resulting in series[1], I only found one public header with an incorrect guard.
/Bruce [1]http://patches.dpdk.org/project/dpdk/list/?series=21466