Skip to content

Commit a2d16f3

Browse files
authored
Extern C blocks (#1352) (#4044)
* Add extern C guard blocks to SDK header files #1352 * fixed some extern C blocks in core and libraries
1 parent 1cd4a00 commit a2d16f3

21 files changed

+165
-11
lines changed

cores/esp8266/pgmspace.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
#include <stdint.h>
55
#include <stdio.h>
66

7-
#ifdef __cplusplus
8-
extern "C" {
9-
#endif
107

118
#ifdef __ets__
129

@@ -26,6 +23,10 @@ extern "C" {
2623
#endif // __ets__
2724

2825

26+
#ifdef __cplusplus
27+
extern "C" {
28+
#endif
29+
2930
#define _SFR_BYTE(n) (n)
3031

3132
typedef void prog_void;

cores/esp8266/umm_malloc/umm_malloc_cfg.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
#define _UMM_MALLOC_CFG_H
77

88
#include <debug.h>
9-
#ifdef __cplusplus
10-
extern "C" {
11-
#endif
9+
//#ifdef __cplusplus
10+
//extern "C" {
11+
//#endif
1212
#include "c_types.h"
13-
#ifdef __cplusplus
14-
}
15-
#endif
13+
//#ifdef __cplusplus
14+
//}
15+
//#endif
1616
/*
1717
* There are a number of defines you can set at compile time that affect how
1818
* the memory allocator will operate.

libraries/GDBStub/src/internal/gdbstub-entry.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int gdbstub_del_hw_watchpoint(int addr);
1919
extern void* gdbstub_do_break_breakpoint_addr;
2020

2121
#ifdef __cplusplus
22-
{
22+
}
2323
#endif
2424

25-
#endif
25+
#endif

tools/sdk/include/at_custom.h

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727

2828
#include "c_types.h"
2929

30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
3034
typedef struct
3135
{
3236
char *at_cmdName;
@@ -169,4 +173,8 @@ bool at_fake_uart_enable(bool enable,at_fake_uart_tx_func_type at_fake_uart_tx_f
169173
*/
170174
bool at_set_escape_character(uint8 ch);
171175

176+
#ifdef __cplusplus
177+
}
178+
#endif
179+
172180
#endif

tools/sdk/include/espconn.h

+12
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#ifndef __ESPCONN_H__
2626
#define __ESPCONN_H__
2727

28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
2832
typedef sint8 err_t;
2933

3034
typedef void *espconn_handle;
@@ -742,5 +746,13 @@ void espconn_dns_setserver(uint8 numdns, ip_addr_t *dnsserver);
742746
* Returns : dnsserver -- IP address of the DNS server to set
743747
*******************************************************************************/
744748
ip_addr_t espconn_dns_getserver(uint8 numdns);
749+
750+
751+
#ifdef __cplusplus
752+
}
745753
#endif
746754

755+
#endif
756+
757+
758+

tools/sdk/include/espnow.h

+9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
#ifndef __ESPNOW_H__
2626
#define __ESPNOW_H__
2727

28+
29+
#ifdef __cplusplus
30+
extern "C" {
31+
#endif
32+
2833
enum esp_now_role {
2934
ESP_NOW_ROLE_IDLE = 0,
3035
ESP_NOW_ROLE_CONTROLLER,
@@ -70,4 +75,8 @@ int esp_now_get_cnt_info(u8 *all_cnt, u8 *encrypt_cnt);
7075

7176
int esp_now_set_kok(u8 *key, u8 len);
7277

78+
#ifdef __cplusplus
79+
}
80+
#endif
81+
7382
#endif

tools/sdk/include/ets_sys.h

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
#include "eagle_soc.h"
3030
#include <stddef.h>
3131

32+
#ifdef __cplusplus
33+
extern "C" {
34+
#endif
35+
3236
typedef uint32_t ETSSignal;
3337
typedef uint32_t ETSParam;
3438

@@ -213,4 +217,8 @@ bool ets_task(ETSTask task, uint8 prio, ETSEvent *queue, uint8 qlen);
213217
bool ets_post(uint8 prio, ETSSignal sig, ETSParam par);
214218

215219

220+
#ifdef __cplusplus
221+
}
222+
#endif
223+
216224
#endif /* _ETS_SYS_H */

tools/sdk/include/gpio.h

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#ifndef _GPIO_H_
2626
#define _GPIO_H_
2727

28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
2832
#define GPIO_PIN_ADDR(i) (GPIO_PIN0_ADDRESS + i*4)
2933

3034
#define GPIO_ID_IS_PIN_REGISTER(reg_id) \
@@ -116,4 +120,8 @@ void gpio_pin_wakeup_disable();
116120

117121
void gpio_pin_intr_state_set(uint32 i, GPIO_INT_TYPE intr_state);
118122

123+
#ifdef __cplusplus
124+
}
125+
#endif
126+
119127
#endif // _GPIO_H_

tools/sdk/include/ip_addr.h

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727

2828
#include "c_types.h"
2929

30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
3034
struct ip_addr {
3135
uint32 addr;
3236
};
@@ -84,4 +88,9 @@ uint32 ipaddr_addr(const char *cp);
8488

8589
#define IPSTR "%d.%d.%d.%d"
8690

91+
92+
#ifdef __cplusplus
93+
}
94+
#endif
95+
8796
#endif /* __IP_ADDR_H__ */

tools/sdk/include/mem.h

+9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#ifndef __MEM_H__
2626
#define __MEM_H__
2727

28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
2832
/* Note: check_memleak_debug_enable is a weak function inside SDK.
2933
* please copy following codes to user_main.c.
3034
#include "mem.h"
@@ -77,5 +81,10 @@ do{\
7781

7882
#endif
7983

84+
85+
#ifdef __cplusplus
86+
}
87+
#endif
88+
8089
#endif
8190

tools/sdk/include/mesh.h

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "ip_addr.h"
2828
#include "user_interface.h"
2929
#include "espconn.h"
30+
3031
#ifdef __cplusplus
3132
extern "C" {
3233
#endif

tools/sdk/include/osapi.h

+9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
#include <string.h>
2929
#include "user_config.h"
3030

31+
#ifdef __cplusplus
32+
extern "C" {
33+
#endif
34+
3135
#define os_bzero ets_bzero
3236
#define os_delay_us ets_delay_us
3337
#define os_install_putc1 ets_install_putc1
@@ -77,5 +81,10 @@ extern int os_printf_plus(const char * format, ...) __attribute__ ((format (prin
7781
unsigned long os_random(void);
7882
int os_get_random(unsigned char *buf, size_t len);
7983

84+
85+
#ifdef __cplusplus
86+
}
87+
#endif
88+
8089
#endif
8190

tools/sdk/include/ping.h

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#ifndef __PING_H__
2626
#define __PING_H__
2727

28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
2831

2932
typedef void (* ping_recv_function)(void* arg, void *pdata);
3033
typedef void (* ping_sent_function)(void* arg, void *pdata);
@@ -53,4 +56,8 @@ bool ping_start(struct ping_option *ping_opt);
5356
bool ping_regist_recv(struct ping_option *ping_opt, ping_recv_function ping_recv);
5457
bool ping_regist_sent(struct ping_option *ping_opt, ping_sent_function ping_sent);
5558

59+
#ifdef __cplusplus
60+
}
61+
#endif
62+
5663
#endif /* __PING_H__ */

tools/sdk/include/pwm.h

+9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#ifndef __PWM_H__
2626
#define __PWM_H__
2727

28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
2832
/*pwm.h: function and macro definition of PWM API , driver level */
2933
/*user_light.h: user interface for light API, user level*/
3034
/*user_light_adj: API for color changing and lighting effects, user level*/
@@ -54,5 +58,10 @@ uint32 pwm_get_period(void);
5458
uint32 get_pwm_version(void);
5559
void set_pwm_debug_en(uint8 print_en);
5660

61+
62+
#ifdef __cplusplus
63+
}
64+
#endif
65+
5766
#endif
5867

tools/sdk/include/simple_pair.h

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#ifndef __SIMPLE_PAIR_H__
2626
#define __SIMPLE_PAIR_H__
2727

28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
2832
typedef enum {
2933
SP_ST_STA_FINISH = 0,
3034
SP_ST_AP_FINISH = 0,
@@ -61,4 +65,8 @@ int simple_pair_set_peer_ref(u8 *peer_mac, u8 *tmp_key, u8 *ex_key);
6165
int simple_pair_get_peer_ref(u8 *peer_mac, u8 *tmp_key, u8 *ex_key);
6266

6367

68+
#ifdef __cplusplus
69+
}
70+
#endif
71+
6472
#endif /* __SIMPLE_PAIR_H__ */

tools/sdk/include/smartconfig.h

+9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#ifndef __SMARTCONFIG_H__
2626
#define __SMARTCONFIG_H__
2727

28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
2832
typedef enum {
2933
SC_STATUS_WAIT = 0,
3034
SC_STATUS_FIND_CHANNEL,
@@ -47,4 +51,9 @@ bool smartconfig_stop(void);
4751
bool esptouch_set_timeout(uint8 time_s); //15s~255s, offset:45s
4852
bool smartconfig_set_type(sc_type type);
4953

54+
55+
#ifdef __cplusplus
56+
}
57+
#endif
58+
5059
#endif

tools/sdk/include/sntp.h

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
#else
88
#include "ip_addr.h"
99
#endif
10+
11+
#ifdef __cplusplus
12+
extern "C" {
13+
#endif
14+
1015
/**
1116
* get the seconds since Jan 01, 1970, 00:00 (GMT + 8)
1217
*/
@@ -65,4 +70,9 @@ char *sntp_getservername(unsigned char idx);
6570

6671
#define sntp_servermode_dhcp(x)
6772

73+
74+
#ifdef __cplusplus
75+
}
76+
#endif
77+
6878
#endif

tools/sdk/include/spi_flash.h

+9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#ifndef SPI_FLASH_H
2626
#define SPI_FLASH_H
2727

28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
2832
typedef enum {
2933
SPI_FLASH_RESULT_OK,
3034
SPI_FLASH_RESULT_ERR,
@@ -60,4 +64,9 @@ void spi_flash_set_read_func(user_spi_flash_read read);
6064
bool spi_flash_erase_protect_enable(void);
6165
bool spi_flash_erase_protect_disable(void);
6266

67+
68+
#ifdef __cplusplus
69+
}
70+
#endif
71+
6372
#endif

tools/sdk/include/upgrade.h

+11
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
#ifndef __UPGRADE_H__
2626
#define __UPGRADE_H__
2727

28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
2833
#define SPI_FLASH_SEC_SIZE 4096
2934
#define LIMIT_ERASE_SIZE 0x10000
3035

@@ -71,4 +76,10 @@ bool system_upgrade_start_ssl(struct upgrade_server_info *server); // not suppor
7176
#else
7277
bool system_upgrade_start(struct upgrade_server_info *server);
7378
#endif
79+
80+
81+
#ifdef __cplusplus
82+
}
83+
#endif
84+
7485
#endif

tools/sdk/include/user_interface.h

+9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
#include "spi_flash.h"
3838
#include "gpio.h"
3939

40+
#ifdef __cplusplus
41+
extern "C" {
42+
#endif
43+
4044
#ifndef MAC2STR
4145
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
4246
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
@@ -651,4 +655,9 @@ void wifi_disable_gpio_wakeup(void);
651655

652656
void uart_div_modify(uint8 uart_no, uint32 DivLatchValue);
653657

658+
#ifdef __cplusplus
659+
}
660+
#endif
661+
662+
654663
#endif

0 commit comments

Comments
 (0)