include/bluetooth: rearrange for standard use of extern "C"

Consistently place C++ use of extern "C" after all include directives,
within the negative branch of _ASMLANGUAGE if used.

Background from issue #17997:

Declarations that use C linkage should be placed within extern "C"
so the language linkage is correct when the header is included by
a C++ compiler.

Similarly #include directives should be outside the extern "C" to
ensure the language-specific default linkage is applied to any
declarations provided by the included header.

See: https://en.cppreference.com/w/cpp/language/language_linkage
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2019-08-12 12:54:12 -05:00 committed by Carles Cufí
parent 754d1274a7
commit 5412409781
9 changed files with 26 additions and 27 deletions

View file

@ -10,12 +10,12 @@
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_A2DP_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_A2DP_H_
#include <bluetooth/avdtp.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <bluetooth/avdtp.h>
/** @brief Stream Structure */
struct bt_a2dp_stream {
/* TODO */

View file

@ -10,12 +10,12 @@
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_ATT_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_ATT_H_
#include <sys/slist.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/slist.h>
/* Error codes for Error response PDU */
#define BT_ATT_ERR_INVALID_HANDLE 0x01
#define BT_ATT_ERR_READ_NOT_PERMITTED 0x02

View file

@ -17,15 +17,15 @@
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Opaque type representing a connection to a remote device */
struct bt_conn;

View file

@ -17,10 +17,6 @@
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include <sys/types.h>
#include <sys/util.h>
@ -28,6 +24,10 @@ extern "C" {
#include <bluetooth/uuid.h>
#include <bluetooth/att.h>
#ifdef __cplusplus
extern "C" {
#endif
/* GATT attribute permission bit field values */
enum {
/** No operations supported, e.g. for notify-only */

View file

@ -17,15 +17,15 @@
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/atomic.h>
#include <bluetooth/buf.h>
#include <bluetooth/conn.h>
#include <bluetooth/hci.h>
#ifdef __cplusplus
extern "C" {
#endif
/* L2CAP header size, used for buffer size calculations */
#define BT_L2CAP_HDR_SIZE 4

View file

@ -17,13 +17,13 @@
* @{
*/
#include <bluetooth/buf.h>
#include <bluetooth/conn.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <bluetooth/buf.h>
#include <bluetooth/conn.h>
/* RFCOMM channels (1-30): pre-allocated for profiles to avoid conflicts */
enum {
BT_RFCOMM_CHAN_HFP_HF = 1,

View file

@ -17,13 +17,13 @@
* @{
*/
#include <bluetooth/uuid.h>
#include <bluetooth/conn.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <bluetooth/uuid.h>
#include <bluetooth/conn.h>
/*
* All definitions are based on Bluetooth Assigned Numbers
* of the Bluetooth Specification
@ -601,6 +601,7 @@ int bt_sdp_get_profile_version(const struct net_buf *buf, u16_t profile,
* @return 0 on success if feature found and valid, negative in case any error
*/
int bt_sdp_get_features(const struct net_buf *buf, u16_t *features);
#ifdef __cplusplus
}
#endif

View file

@ -18,12 +18,12 @@
* as a part of ongoing development.
*/
#include <zephyr/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <zephyr/types.h>
/** @brief Read battery level value.
*
* Read the characteristic value of the battery level

View file

@ -14,6 +14,7 @@
#include <linker/sections.h>
#include <offsets.h>
#include <zephyr.h>
#include <logging/log.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
@ -32,8 +33,6 @@ extern "C" {
#define LOG_LEVEL CONFIG_BT_LOG_LEVEL
#endif
#include <logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#define BT_DBG(fmt, ...) LOG_DBG(fmt, ##__VA_ARGS__)
@ -62,4 +61,3 @@ const char *bt_addr_le_str_real(const bt_addr_le_t *addr);
#endif
#endif /* __BT_LOG_H */