Do not include headers inside __BEGIN_DECLS ... __END_DECLS blocks.
We don't have C++ unsafe headers (anymore). I added a test to fix_headers.sh that checks if certain "unsafe" headers are ONLY included inside a __BEGIN_DECLS ... __END_DECLS (because after all, they are unsafe), as well as checking that no other header files are included inside such a block. The rationale of the latter is that if a file is a C header and it declares function prototypes (otherwise it doesn't matter) and is sometimes included outside a __BEGIN_DECLS ... __END_DECLS block (from a C++ source file) then it has to be C++ safe and doesn't ever to be included from inside such a block; while if a file is a C++ header then obviously it should never be included from such a block. fix_headers.sh subsequently found several safe headers to be included from inside such a block, and those that were (apparently in the past) unsafe were included only sometimes inside such a block and often outside it. I had a look at those files and saw that at least an attempt has been made to make them C++ safe, but especially because they already are included OFTEN outside a __BEGIN_DECLS ... __END_DECLS (from C++ source files) the best decision seems to treat them as safe. This is not risky: .c files that define such functions still generate C-linkage for their functions. If a C++ unsafe C header is included outside a __BEGIN_DECLS ... __END_DECLS block then the only possible result would be an undefined reference to a function with C++-linkage that will not exist. Aka, when something links after this commit, then the commit was correct. I did build all targets and they all linked.
Showing
- src/drivers/boards/aerocore/board_config.h 2 additions, 3 deletionssrc/drivers/boards/aerocore/board_config.h
- src/drivers/boards/asc-v1/board_config.h 4 additions, 3 deletionssrc/drivers/boards/asc-v1/board_config.h
- src/drivers/boards/crazyflie/board_config.h 1 addition, 9 deletionssrc/drivers/boards/crazyflie/board_config.h
- src/drivers/boards/mindpx-v2/board_config.h 2 additions, 3 deletionssrc/drivers/boards/mindpx-v2/board_config.h
- src/drivers/boards/px4-stm32f4discovery/board_config.h 2 additions, 3 deletionssrc/drivers/boards/px4-stm32f4discovery/board_config.h
- src/drivers/boards/px4fmu-v1/board_config.h 2 additions, 3 deletionssrc/drivers/boards/px4fmu-v1/board_config.h
- src/drivers/boards/px4fmu-v2/board_config.h 3 additions, 4 deletionssrc/drivers/boards/px4fmu-v2/board_config.h
- src/drivers/boards/px4fmu-v4/board_config.h 2 additions, 4 deletionssrc/drivers/boards/px4fmu-v4/board_config.h
- src/drivers/boards/px4io-v1/board_config.h 0 additions, 1 deletionsrc/drivers/boards/px4io-v1/board_config.h
- src/drivers/boards/px4io-v2/board_config.h 0 additions, 2 deletionssrc/drivers/boards/px4io-v2/board_config.h
- src/drivers/boards/tap-v1/board_config.h 4 additions, 4 deletionssrc/drivers/boards/tap-v1/board_config.h
- src/drivers/drv_pwm_output.h 3 additions, 1 deletionsrc/drivers/drv_pwm_output.h
- src/lib/geo/geo.h 2 additions, 1 deletionsrc/lib/geo/geo.h
- src/modules/mavlink/mavlink_bridge_header.h 1 addition, 2 deletionssrc/modules/mavlink/mavlink_bridge_header.h
- src/modules/systemlib/cpuload.h 2 additions, 2 deletionssrc/modules/systemlib/cpuload.h
- src/modules/systemlib/otp.h 1 addition, 2 deletionssrc/modules/systemlib/otp.h
- src/modules/systemlib/printload.h 3 additions, 2 deletionssrc/modules/systemlib/printload.h
Loading
Please register or sign in to comment