net: Move include files outside of extern "C" block

This is related to findings in #17997 and changes network related
header files to have include files outside of extern "C" { } block.

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: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2019-08-05 17:18:46 +03:00
commit 5c05ef5101
19 changed files with 68 additions and 74 deletions

View file

@ -7,17 +7,9 @@
#ifndef ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_LOG_H_ #ifndef ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_LOG_H_
#define ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_LOG_H_ #define ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_LOG_H_
#ifdef __cplusplus
extern "C" {
#endif
#define LOG_MODULE_NAME wifi_simplelink #define LOG_MODULE_NAME wifi_simplelink
#define LOG_LEVEL CONFIG_WIFI_LOG_LEVEL #define LOG_LEVEL CONFIG_WIFI_LOG_LEVEL
#include <logging/log.h> #include <logging/log.h>
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_LOG_H_ */ #endif /* ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_LOG_H_ */

View file

@ -8,12 +8,12 @@
#ifndef ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_SUPPORT_H_ #ifndef ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_SUPPORT_H_
#define ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_SUPPORT_H_ #define ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_SUPPORT_H_
#include <net/wifi_mgmt.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <net/wifi_mgmt.h>
#define SSID_LEN_MAX (32) #define SSID_LEN_MAX (32)
#define BSSID_LEN_MAX (6) #define BSSID_LEN_MAX (6)

View file

@ -11,6 +11,9 @@
#ifndef ZEPHYR_INCLUDE_NET_DHCPV4_H_ #ifndef ZEPHYR_INCLUDE_NET_DHCPV4_H_
#define ZEPHYR_INCLUDE_NET_DHCPV4_H_ #define ZEPHYR_INCLUDE_NET_DHCPV4_H_
#include <sys/slist.h>
#include <zephyr/types.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -22,9 +25,6 @@ extern "C" {
* @{ * @{
*/ */
#include <sys/slist.h>
#include <zephyr/types.h>
/** @cond INTERNAL_HIDDEN */ /** @cond INTERNAL_HIDDEN */
/** Current state of DHCPv4 client address negotiation. /** Current state of DHCPv4 client address negotiation.

View file

@ -20,9 +20,6 @@
*/ */
#ifndef ZEPHYR_INCLUDE_NET_HTTP_PARSER_H_ #ifndef ZEPHYR_INCLUDE_NET_HTTP_PARSER_H_
#define ZEPHYR_INCLUDE_NET_HTTP_PARSER_H_ #define ZEPHYR_INCLUDE_NET_HTTP_PARSER_H_
#ifdef __cplusplus
extern "C" {
#endif
/* Also update SONAME in the Makefile whenever you change these. */ /* Also update SONAME in the Makefile whenever you change these. */
#define HTTP_PARSER_VERSION_MAJOR 2 #define HTTP_PARSER_VERSION_MAJOR 2
@ -49,6 +46,10 @@ typedef unsigned __int64 u64_t;
#include <net/http_parser_state.h> #include <net/http_parser_state.h>
#include <net/http_parser_url.h> #include <net/http_parser_url.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Maximium header size allowed. If the macro is not defined /* Maximium header size allowed. If the macro is not defined
* before including this header then the default is used. To * before including this header then the default is used. To
* change the maximum header size, define the macro in the build * change the maximum header size, define the macro in the build

View file

@ -20,15 +20,16 @@
*/ */
#ifndef ZEPHYR_INCLUDE_NET_HTTP_PARSER_URL_H_ #ifndef ZEPHYR_INCLUDE_NET_HTTP_PARSER_URL_H_
#define ZEPHYR_INCLUDE_NET_HTTP_PARSER_URL_H_ #define ZEPHYR_INCLUDE_NET_HTTP_PARSER_URL_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/types.h> #include <sys/types.h>
#include <zephyr/types.h> #include <zephyr/types.h>
#include <stddef.h> #include <stddef.h>
#include <net/http_parser_state.h> #include <net/http_parser_state.h>
#ifdef __cplusplus
extern "C" {
#endif
enum http_parser_url_fields { enum http_parser_url_fields {
UF_SCHEMA = 0 UF_SCHEMA = 0
, UF_HOST = 1 , UF_HOST = 1

View file

@ -13,12 +13,12 @@
#ifndef ZEPHYR_INCLUDE_NET_NET_CORE_H_ #ifndef ZEPHYR_INCLUDE_NET_NET_CORE_H_
#define ZEPHYR_INCLUDE_NET_NET_CORE_H_ #define ZEPHYR_INCLUDE_NET_NET_CORE_H_
#include <stdbool.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <stdbool.h>
/** /**
* @brief Networking * @brief Networking
* @defgroup networking Networking * @defgroup networking Networking

View file

@ -12,12 +12,12 @@
#ifndef ZEPHYR_INCLUDE_NET_NET_EVENT_H_ #ifndef ZEPHYR_INCLUDE_NET_NET_EVENT_H_
#define ZEPHYR_INCLUDE_NET_NET_EVENT_H_ #define ZEPHYR_INCLUDE_NET_NET_EVENT_H_
#include <net/net_ip.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <net/net_ip.h>
/** /**
* @addtogroup net_mgmt * @addtogroup net_mgmt
* @{ * @{

View file

@ -12,6 +12,9 @@
#ifndef ZEPHYR_INCLUDE_NET_NET_MGMT_H_ #ifndef ZEPHYR_INCLUDE_NET_NET_MGMT_H_
#define ZEPHYR_INCLUDE_NET_NET_MGMT_H_ #define ZEPHYR_INCLUDE_NET_NET_MGMT_H_
#include <sys/__assert.h>
#include <net/net_core.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -23,9 +26,6 @@ extern "C" {
* @{ * @{
*/ */
#include <sys/__assert.h>
#include <net/net_core.h>
struct net_if; struct net_if;
/** @cond INTERNAL_HIDDEN */ /** @cond INTERNAL_HIDDEN */

View file

@ -13,15 +13,15 @@
#ifndef ZEPHYR_INCLUDE_NET_SOCKET_CAN_H_ #ifndef ZEPHYR_INCLUDE_NET_SOCKET_CAN_H_
#define ZEPHYR_INCLUDE_NET_SOCKET_CAN_H_ #define ZEPHYR_INCLUDE_NET_SOCKET_CAN_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <zephyr/types.h> #include <zephyr/types.h>
#include <net/net_ip.h> #include <net/net_ip.h>
#include <net/net_if.h> #include <net/net_if.h>
#include <drivers/can.h> #include <drivers/can.h>
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief Socket CAN library * @brief Socket CAN library
* @defgroup socket_can Network Core Library * @defgroup socket_can Network Core Library

View file

@ -13,15 +13,15 @@
#ifndef ZEPHYR_INCLUDE_NET_SOCKET_NET_MGMT_H_ #ifndef ZEPHYR_INCLUDE_NET_SOCKET_NET_MGMT_H_
#define ZEPHYR_INCLUDE_NET_SOCKET_NET_MGMT_H_ #define ZEPHYR_INCLUDE_NET_SOCKET_NET_MGMT_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <zephyr/types.h> #include <zephyr/types.h>
#include <net/net_ip.h> #include <net/net_ip.h>
#include <net/net_if.h> #include <net/net_if.h>
#include <net/net_mgmt.h> #include <net/net_mgmt.h>
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief Socket NET_MGMT library * @brief Socket NET_MGMT library
* @defgroup socket_net_mgmt Network Core Library * @defgroup socket_net_mgmt Network Core Library

View file

@ -12,12 +12,12 @@
#ifndef ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_H_ #ifndef ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_H_
#define ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_H_ #define ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_H_
#include <net/socket_offload_ops.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <net/socket_offload_ops.h>
extern const struct socket_offload *socket_ops; extern const struct socket_offload *socket_ops;
static inline int socket(int family, int type, int proto) static inline int socket(int family, int type, int proto)

View file

@ -12,6 +12,14 @@
#ifndef ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_OPS_H_ #ifndef ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_OPS_H_
#define ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_OPS_H_ #define ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_OPS_H_
#include <sys/types.h>
#include <net/net_ip.h>
#include <net/socket.h> /* needed for struct pollfd */
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief Socket Offload Redirect API * @brief Socket Offload Redirect API
* @defgroup socket_offload Socket offloading interface * @defgroup socket_offload Socket offloading interface
@ -19,14 +27,6 @@
* @{ * @{
*/ */
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/types.h>
#include <net/net_ip.h>
#include <net/socket.h> /* needed for struct pollfd */
/** /**
* @brief An offloaded Socket API interface * @brief An offloaded Socket API interface
* *
@ -68,12 +68,12 @@ struct socket_offload {
*/ */
extern void socket_offload_register(const struct socket_offload *ops); extern void socket_offload_register(const struct socket_offload *ops);
#ifdef __cplusplus
}
#endif
/** /**
* @} * @}
*/ */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_OPS_H_ */ #endif /* ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_OPS_H_ */

View file

@ -7,15 +7,15 @@
#ifndef __ARP_H #ifndef __ARP_H
#define __ARP_H #define __ARP_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined(CONFIG_NET_ARP) #if defined(CONFIG_NET_ARP)
#include <sys/slist.h> #include <sys/slist.h>
#include <net/ethernet.h> #include <net/ethernet.h>
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief Address resolution (ARP) library * @brief Address resolution (ARP) library
* @defgroup arp ARP Library * @defgroup arp ARP Library
@ -71,6 +71,10 @@ void net_arp_init(void);
* @} * @}
*/ */
#ifdef __cplusplus
}
#endif
#else /* CONFIG_NET_ARP */ #else /* CONFIG_NET_ARP */
#define net_arp_prepare(_kt, _u1, _u2) _kt #define net_arp_prepare(_kt, _u1, _u2) _kt
#define net_arp_input(...) NET_OK #define net_arp_input(...) NET_OK
@ -79,8 +83,4 @@ void net_arp_init(void);
#endif /* CONFIG_NET_ARP */ #endif /* CONFIG_NET_ARP */
#ifdef __cplusplus
}
#endif
#endif /* __ARP_H */ #endif /* __ARP_H */

View file

@ -14,15 +14,15 @@
#ifndef __GPTP_DS_H #ifndef __GPTP_DS_H
#define __GPTP_DS_H #define __GPTP_DS_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined(CONFIG_NET_GPTP) #if defined(CONFIG_NET_GPTP)
#include <net/gptp.h> #include <net/gptp.h>
#include "gptp_state.h" #include "gptp_state.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Parameters for PTP data sets. */ /* Parameters for PTP data sets. */
#define GPTP_ALLOWED_LOST_RESP 3 #define GPTP_ALLOWED_LOST_RESP 3
@ -592,10 +592,10 @@ int gptp_get_port_data(struct gptp_domain *domain, int port,
struct gptp_port_bmca_data **port_bmca_data, struct gptp_port_bmca_data **port_bmca_data,
struct net_if **iface); struct net_if **iface);
#endif /* CONFIG_NET_GPTP */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* CONFIG_NET_GPTP */
#endif /* __GPTP_DS_H */ #endif /* __GPTP_DS_H */

View file

@ -14,12 +14,12 @@
#ifndef __GPTP_MD_H #ifndef __GPTP_MD_H
#define __GPTP_MD_H #define __GPTP_MD_H
#include <net/gptp.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <net/gptp.h>
/** /**
* @brief Media Dependent Sync Information. * @brief Media Dependent Sync Information.
* *

View file

@ -14,14 +14,14 @@
#ifndef __GPTP_MESSAGES_H #ifndef __GPTP_MESSAGES_H
#define __GPTP_MESSAGES_H #define __GPTP_MESSAGES_H
#ifdef __cplusplus
extern "C" {
#endif
#include <net/net_pkt.h> #include <net/net_pkt.h>
#include <net/ethernet.h> #include <net/ethernet.h>
#include <net/gptp.h> #include <net/gptp.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Helpers to access gPTP messages. */ /* Helpers to access gPTP messages. */
#define GPTP_HDR(pkt) gptp_get_hdr(pkt) #define GPTP_HDR(pkt) gptp_get_hdr(pkt)
#define GPTP_ANNOUNCE(pkt) ((struct gptp_announce *)gptp_data(pkt)) #define GPTP_ANNOUNCE(pkt) ((struct gptp_announce *)gptp_data(pkt))

View file

@ -14,12 +14,12 @@
#ifndef __GPTP_MI_H #ifndef __GPTP_MI_H
#define __GPTP_MI_H #define __GPTP_MI_H
#include "gptp_md.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "gptp_md.h"
/** /**
* @brief Media Independent Sync Information. * @brief Media Independent Sync Information.
* *

View file

@ -14,12 +14,12 @@
#ifndef __GPTP_PRIVATE_H #ifndef __GPTP_PRIVATE_H
#define __GPTP_PRIVATE_H #define __GPTP_PRIVATE_H
#include <net/gptp.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <net/gptp.h>
/* Common defines for the gPTP stack. */ /* Common defines for the gPTP stack. */
#define GPTP_THREAD_WAIT_TIMEOUT_MS 1 #define GPTP_THREAD_WAIT_TIMEOUT_MS 1
#define GPTP_MULTIPLE_PDELAY_RESP_WAIT K_MINUTES(5) #define GPTP_MULTIPLE_PDELAY_RESP_WAIT K_MINUTES(5)

View file

@ -13,12 +13,12 @@
#ifndef __GPTP_STATE_H #ifndef __GPTP_STATE_H
#define __GPTP_STATE_H #define __GPTP_STATE_H
#include "gptp_mi.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "gptp_mi.h"
/* PDelayRequest states. */ /* PDelayRequest states. */
enum gptp_pdelay_req_states { enum gptp_pdelay_req_states {
GPTP_PDELAY_REQ_NOT_ENABLED, GPTP_PDELAY_REQ_NOT_ENABLED,