Skip to content

Commit 5c05ef5

Browse files
committed
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 <[email protected]>
1 parent 27a5cb6 commit 5c05ef5

File tree

19 files changed

+68
-74
lines changed

19 files changed

+68
-74
lines changed

drivers/wifi/simplelink/simplelink_log.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,9 @@
77
#ifndef ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_LOG_H_
88
#define ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_LOG_H_
99

10-
#ifdef __cplusplus
11-
extern "C" {
12-
#endif
13-
1410
#define LOG_MODULE_NAME wifi_simplelink
1511
#define LOG_LEVEL CONFIG_WIFI_LOG_LEVEL
1612

1713
#include <logging/log.h>
1814

19-
#ifdef __cplusplus
20-
}
21-
#endif
22-
2315
#endif /* ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_LOG_H_ */

drivers/wifi/simplelink/simplelink_support.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
#ifndef ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_SUPPORT_H_
99
#define ZEPHYR_DRIVERS_WIFI_SIMPLELINK_SIMPLELINK_SUPPORT_H_
1010

11+
#include <net/wifi_mgmt.h>
12+
1113
#ifdef __cplusplus
1214
extern "C" {
1315
#endif
1416

15-
#include <net/wifi_mgmt.h>
16-
1717
#define SSID_LEN_MAX (32)
1818
#define BSSID_LEN_MAX (6)
1919

include/net/dhcpv4.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#ifndef ZEPHYR_INCLUDE_NET_DHCPV4_H_
1212
#define ZEPHYR_INCLUDE_NET_DHCPV4_H_
1313

14+
#include <sys/slist.h>
15+
#include <zephyr/types.h>
16+
1417
#ifdef __cplusplus
1518
extern "C" {
1619
#endif
@@ -22,9 +25,6 @@ extern "C" {
2225
* @{
2326
*/
2427

25-
#include <sys/slist.h>
26-
#include <zephyr/types.h>
27-
2828
/** @cond INTERNAL_HIDDEN */
2929

3030
/** Current state of DHCPv4 client address negotiation.

include/net/http_parser.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
*/
2121
#ifndef ZEPHYR_INCLUDE_NET_HTTP_PARSER_H_
2222
#define ZEPHYR_INCLUDE_NET_HTTP_PARSER_H_
23-
#ifdef __cplusplus
24-
extern "C" {
25-
#endif
2623

2724
/* Also update SONAME in the Makefile whenever you change these. */
2825
#define HTTP_PARSER_VERSION_MAJOR 2
@@ -49,6 +46,10 @@ typedef unsigned __int64 u64_t;
4946
#include <net/http_parser_state.h>
5047
#include <net/http_parser_url.h>
5148

49+
#ifdef __cplusplus
50+
extern "C" {
51+
#endif
52+
5253
/* Maximium header size allowed. If the macro is not defined
5354
* before including this header then the default is used. To
5455
* change the maximum header size, define the macro in the build

include/net/http_parser_url.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@
2020
*/
2121
#ifndef ZEPHYR_INCLUDE_NET_HTTP_PARSER_URL_H_
2222
#define ZEPHYR_INCLUDE_NET_HTTP_PARSER_URL_H_
23-
#ifdef __cplusplus
24-
extern "C" {
25-
#endif
2623

2724
#include <sys/types.h>
2825
#include <zephyr/types.h>
2926
#include <stddef.h>
3027
#include <net/http_parser_state.h>
3128

29+
#ifdef __cplusplus
30+
extern "C" {
31+
#endif
32+
3233
enum http_parser_url_fields {
3334
UF_SCHEMA = 0
3435
, UF_HOST = 1

include/net/net_core.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
#ifndef ZEPHYR_INCLUDE_NET_NET_CORE_H_
1414
#define ZEPHYR_INCLUDE_NET_NET_CORE_H_
1515

16+
#include <stdbool.h>
17+
1618
#ifdef __cplusplus
1719
extern "C" {
1820
#endif
1921

20-
#include <stdbool.h>
21-
2222
/**
2323
* @brief Networking
2424
* @defgroup networking Networking

include/net/net_event.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
#ifndef ZEPHYR_INCLUDE_NET_NET_EVENT_H_
1313
#define ZEPHYR_INCLUDE_NET_NET_EVENT_H_
1414

15+
#include <net/net_ip.h>
16+
1517
#ifdef __cplusplus
1618
extern "C" {
1719
#endif
1820

19-
#include <net/net_ip.h>
20-
2121
/**
2222
* @addtogroup net_mgmt
2323
* @{

include/net/net_mgmt.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#ifndef ZEPHYR_INCLUDE_NET_NET_MGMT_H_
1313
#define ZEPHYR_INCLUDE_NET_NET_MGMT_H_
1414

15+
#include <sys/__assert.h>
16+
#include <net/net_core.h>
17+
1518
#ifdef __cplusplus
1619
extern "C" {
1720
#endif
@@ -23,9 +26,6 @@ extern "C" {
2326
* @{
2427
*/
2528

26-
#include <sys/__assert.h>
27-
#include <net/net_core.h>
28-
2929
struct net_if;
3030

3131
/** @cond INTERNAL_HIDDEN */

include/net/socket_can.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
#ifndef ZEPHYR_INCLUDE_NET_SOCKET_CAN_H_
1414
#define ZEPHYR_INCLUDE_NET_SOCKET_CAN_H_
1515

16-
#ifdef __cplusplus
17-
extern "C" {
18-
#endif
19-
2016
#include <zephyr/types.h>
2117
#include <net/net_ip.h>
2218
#include <net/net_if.h>
2319
#include <drivers/can.h>
2420

21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
2525
/**
2626
* @brief Socket CAN library
2727
* @defgroup socket_can Network Core Library

include/net/socket_net_mgmt.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
#ifndef ZEPHYR_INCLUDE_NET_SOCKET_NET_MGMT_H_
1414
#define ZEPHYR_INCLUDE_NET_SOCKET_NET_MGMT_H_
1515

16-
#ifdef __cplusplus
17-
extern "C" {
18-
#endif
19-
2016
#include <zephyr/types.h>
2117
#include <net/net_ip.h>
2218
#include <net/net_if.h>
2319
#include <net/net_mgmt.h>
2420

21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
2525
/**
2626
* @brief Socket NET_MGMT library
2727
* @defgroup socket_net_mgmt Network Core Library

0 commit comments

Comments
 (0)