mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 03:23:34 +08:00
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.
This commit is contained in:
@@ -47,9 +47,6 @@
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* these headers are not C++ safe */
|
||||
#include <stm32.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@@ -189,6 +186,8 @@ __BEGIN_DECLS
|
||||
{GPIO_GPIO10_INPUT, GPIO_GPIO10_OUTPUT, 0}, \
|
||||
{GPIO_GPIO11_INPUT, GPIO_GPIO11_OUTPUT, 0}, }
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/****************************************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************************************/
|
||||
|
||||
@@ -50,9 +50,6 @@
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* these headers are not C++ safe */
|
||||
#include <stm32.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@@ -259,6 +256,9 @@ __BEGIN_DECLS
|
||||
#define TEMP_CONTROL(_on_true) px4_arch_gpiowrite(GPIO_TEMP_CONT, (_on_true))
|
||||
|
||||
#define FLASH_BASED_PARAMS
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/****************************************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************************************/
|
||||
@@ -351,4 +351,5 @@ bool board_pwr_button_down(void);
|
||||
void board_pwr(bool on_not_off);
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
@@ -47,9 +47,6 @@
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* these headers are not C++ safe */
|
||||
#include <stm32.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@@ -168,8 +165,7 @@ __BEGIN_DECLS
|
||||
|
||||
#define BOARD_FMU_GPIO_TAB { {0, 0, 0}, }
|
||||
|
||||
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/****************************************************************************************************
|
||||
* Public Types
|
||||
@@ -219,9 +215,6 @@ extern void board_peripheral_reset(int ms);
|
||||
int nsh_archinitialize(void);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_i2c_initialize
|
||||
*
|
||||
@@ -232,7 +225,6 @@ int nsh_archinitialize(void);
|
||||
|
||||
int board_i2c_initialize(void);
|
||||
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
@@ -47,9 +47,6 @@
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* these headers are not C++ safe */
|
||||
#include <stm32.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@@ -328,6 +325,8 @@ __BEGIN_DECLS
|
||||
|
||||
#define BOARD_DMA_ALLOC_POOL_SIZE 5120
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/****************************************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************************************/
|
||||
|
||||
@@ -47,9 +47,6 @@
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* these headers are not C++ safe */
|
||||
#include <stm32.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@@ -89,6 +86,8 @@ __BEGIN_DECLS
|
||||
|
||||
#define BOARD_NAME "PX4_STM32F4DISCOVERY"
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/****************************************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************************************/
|
||||
|
||||
@@ -47,9 +47,6 @@
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* these headers are not C++ safe */
|
||||
#include <stm32.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@@ -224,6 +221,8 @@ __BEGIN_DECLS
|
||||
*/
|
||||
#define BOARD_HAS_MULTI_PURPOSE_GPIO 1
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/****************************************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************************************/
|
||||
|
||||
@@ -47,9 +47,6 @@
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* these headers are not C++ safe */
|
||||
#include <stm32.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@@ -271,8 +268,10 @@ __BEGIN_DECLS
|
||||
{GPIO_VDD_5V_PERIPH_OC, 0, 0}, }
|
||||
|
||||
/* This board provides a DMA pool and APIs */
|
||||
|
||||
#define BOARD_DMA_ALLOC_POOL_SIZE 5120
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/****************************************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************************************/
|
||||
|
||||
@@ -47,9 +47,6 @@
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* these headers are not C++ safe */
|
||||
#include <stm32.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@@ -298,9 +295,10 @@ __BEGIN_DECLS
|
||||
{GPIO_VDD_BRICK_VALID, 0, 0}, }
|
||||
|
||||
/* This board provides a DMA pool and APIs */
|
||||
|
||||
#define BOARD_DMA_ALLOC_POOL_SIZE 5120
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/****************************************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************************************/
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* these headers are not C++ safe */
|
||||
#include <stm32.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* these headers are not C++ safe */
|
||||
#include <stm32.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@@ -143,4 +142,3 @@
|
||||
#define LED_SIGNAL 5 /* LED? + LED? */
|
||||
#define LED_ASSERTION 6 /* LED? + LED? + LED? */
|
||||
#define LED_PANIC 7 /* N/C + N/C + N/C + LED? */
|
||||
|
||||
|
||||
@@ -48,9 +48,6 @@
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* these headers are not C++ safe */
|
||||
#include <stm32.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@@ -262,6 +259,9 @@ __BEGIN_DECLS
|
||||
#define TEMP_CONTROL(_on_true) px4_arch_gpiowrite(GPIO_TEMP_CONT, (_on_true))
|
||||
|
||||
#define FLASH_BASED_PARAMS
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/****************************************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************************************/
|
||||
@@ -320,7 +320,6 @@ extern int board_sdio_initialize(void);
|
||||
int nsh_archinitialize(void);
|
||||
#endif
|
||||
|
||||
|
||||
/************************************************************************************
|
||||
* Name: board_pwr_init()
|
||||
*
|
||||
@@ -364,4 +363,5 @@ void board_pwr(bool on_not_off);
|
||||
int board_i2c_initialize(void);
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
@@ -44,6 +44,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <px4_defines.h>
|
||||
|
||||
#include "uORB/topics/output_pwm.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
@@ -61,7 +64,6 @@ __BEGIN_DECLS
|
||||
#define PWM_OUTPUT_BASE_DEVICE_PATH "/dev/pwm_output"
|
||||
#define PWM_OUTPUT0_DEVICE_PATH "/dev/pwm_output0"
|
||||
|
||||
#include <uORB/topics/output_pwm.h>
|
||||
#define pwm_output_values output_pwm_s
|
||||
|
||||
#ifndef PWM_OUTPUT_MAX_CHANNELS
|
||||
|
||||
Reference in New Issue
Block a user