Skip to content
Permalink
Browse files

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>
  • Loading branch information...
jukkar committed Aug 5, 2019
1 parent 27a5cb6 commit 5c05ef5101b454c8dbe00c004089b34172892aab
@@ -7,17 +7,9 @@
#ifndef 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_LEVEL CONFIG_WIFI_LOG_LEVEL

#include <logging/log.h>

#ifdef __cplusplus
}
#endif

#endif /* ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_LOG_H_ */
@@ -8,12 +8,12 @@
#ifndef ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_SUPPORT_H_
#define ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_SUPPORT_H_

#include <net/wifi_mgmt.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <net/wifi_mgmt.h>

#define SSID_LEN_MAX (32)
#define BSSID_LEN_MAX (6)

@@ -11,6 +11,9 @@
#ifndef ZEPHYR_INCLUDE_NET_DHCPV4_H_
#define ZEPHYR_INCLUDE_NET_DHCPV4_H_

#include <sys/slist.h>
#include <zephyr/types.h>

#ifdef __cplusplus
extern "C" {
#endif
@@ -22,9 +25,6 @@ extern "C" {
* @{
*/

#include <sys/slist.h>
#include <zephyr/types.h>

/** @cond INTERNAL_HIDDEN */

/** Current state of DHCPv4 client address negotiation.
@@ -20,9 +20,6 @@
*/
#ifndef 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. */
#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_url.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Maximium header size allowed. If the macro is not defined
* before including this header then the default is used. To
* change the maximum header size, define the macro in the build
@@ -20,15 +20,16 @@
*/
#ifndef 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 <zephyr/types.h>
#include <stddef.h>
#include <net/http_parser_state.h>

#ifdef __cplusplus
extern "C" {
#endif

enum http_parser_url_fields {
UF_SCHEMA = 0
, UF_HOST = 1
@@ -13,12 +13,12 @@
#ifndef ZEPHYR_INCLUDE_NET_NET_CORE_H_
#define ZEPHYR_INCLUDE_NET_NET_CORE_H_

#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <stdbool.h>

/**
* @brief Networking
* @defgroup networking Networking
@@ -12,12 +12,12 @@
#ifndef ZEPHYR_INCLUDE_NET_NET_EVENT_H_
#define ZEPHYR_INCLUDE_NET_NET_EVENT_H_

#include <net/net_ip.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <net/net_ip.h>

/**
* @addtogroup net_mgmt
* @{
@@ -12,6 +12,9 @@
#ifndef ZEPHYR_INCLUDE_NET_NET_MGMT_H_
#define ZEPHYR_INCLUDE_NET_NET_MGMT_H_

#include <sys/__assert.h>
#include <net/net_core.h>

#ifdef __cplusplus
extern "C" {
#endif
@@ -23,9 +26,6 @@ extern "C" {
* @{
*/

#include <sys/__assert.h>
#include <net/net_core.h>

struct net_if;

/** @cond INTERNAL_HIDDEN */
@@ -13,15 +13,15 @@
#ifndef ZEPHYR_INCLUDE_NET_SOCKET_CAN_H_
#define ZEPHYR_INCLUDE_NET_SOCKET_CAN_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <zephyr/types.h>
#include <net/net_ip.h>
#include <net/net_if.h>
#include <drivers/can.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Socket CAN library
* @defgroup socket_can Network Core Library
@@ -13,15 +13,15 @@
#ifndef 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 <net/net_ip.h>
#include <net/net_if.h>
#include <net/net_mgmt.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Socket NET_MGMT library
* @defgroup socket_net_mgmt Network Core Library
@@ -12,12 +12,12 @@
#ifndef ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_H_
#define ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_H_

#include <net/socket_offload_ops.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <net/socket_offload_ops.h>

extern const struct socket_offload *socket_ops;

static inline int socket(int family, int type, int proto)
@@ -12,21 +12,21 @@
#ifndef 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
* @defgroup socket_offload Socket offloading interface
* @ingroup networking
* @{
*/

#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
*
@@ -68,12 +68,12 @@ struct socket_offload {
*/
extern void socket_offload_register(const struct socket_offload *ops);

#ifdef __cplusplus
}
#endif

/**
* @}
*/

#ifdef __cplusplus
}
#endif

#endif /* ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_OPS_H_ */
@@ -7,15 +7,15 @@
#ifndef __ARP_H
#define __ARP_H

#ifdef __cplusplus
extern "C" {
#endif

#if defined(CONFIG_NET_ARP)

#include <sys/slist.h>
#include <net/ethernet.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Address resolution (ARP) library
* @defgroup arp ARP Library
@@ -71,6 +71,10 @@ void net_arp_init(void);
* @}
*/

#ifdef __cplusplus
}
#endif

#else /* CONFIG_NET_ARP */
#define net_arp_prepare(_kt, _u1, _u2) _kt
#define net_arp_input(...) NET_OK
@@ -79,8 +83,4 @@ void net_arp_init(void);

#endif /* CONFIG_NET_ARP */

#ifdef __cplusplus
}
#endif

#endif /* __ARP_H */
@@ -14,15 +14,15 @@
#ifndef __GPTP_DS_H
#define __GPTP_DS_H

#ifdef __cplusplus
extern "C" {
#endif

#if defined(CONFIG_NET_GPTP)

#include <net/gptp.h>
#include "gptp_state.h"

#ifdef __cplusplus
extern "C" {
#endif

/* Parameters for PTP data sets. */
#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 net_if **iface);

#endif /* CONFIG_NET_GPTP */

#ifdef __cplusplus
}
#endif

#endif /* CONFIG_NET_GPTP */

#endif /* __GPTP_DS_H */
@@ -14,12 +14,12 @@
#ifndef __GPTP_MD_H
#define __GPTP_MD_H

#include <net/gptp.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <net/gptp.h>

/**
* @brief Media Dependent Sync Information.
*
@@ -14,14 +14,14 @@
#ifndef __GPTP_MESSAGES_H
#define __GPTP_MESSAGES_H

#ifdef __cplusplus
extern "C" {
#endif

#include <net/net_pkt.h>
#include <net/ethernet.h>
#include <net/gptp.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Helpers to access gPTP messages. */
#define GPTP_HDR(pkt) gptp_get_hdr(pkt)
#define GPTP_ANNOUNCE(pkt) ((struct gptp_announce *)gptp_data(pkt))
@@ -14,12 +14,12 @@
#ifndef __GPTP_MI_H
#define __GPTP_MI_H

#include "gptp_md.h"

#ifdef __cplusplus
extern "C" {
#endif

#include "gptp_md.h"

/**
* @brief Media Independent Sync Information.
*
@@ -14,12 +14,12 @@
#ifndef __GPTP_PRIVATE_H
#define __GPTP_PRIVATE_H

#include <net/gptp.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <net/gptp.h>

/* Common defines for the gPTP stack. */
#define GPTP_THREAD_WAIT_TIMEOUT_MS 1
#define GPTP_MULTIPLE_PDELAY_RESP_WAIT K_MINUTES(5)
@@ -13,12 +13,12 @@
#ifndef __GPTP_STATE_H
#define __GPTP_STATE_H

#include "gptp_mi.h"

#ifdef __cplusplus
extern "C" {
#endif

#include "gptp_mi.h"

/* PDelayRequest states. */
enum gptp_pdelay_req_states {
GPTP_PDELAY_REQ_NOT_ENABLED,

0 comments on commit 5c05ef5

Please sign in to comment.
You can’t perform that action at this time.