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

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
* @{

View file

@ -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 */

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -12,6 +12,14 @@
#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
@ -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
*
@ -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_ */