From a2d16f38d48727bba41befadebc590bdd84588ad Mon Sep 17 00:00:00 2001 From: Develo Date: Sat, 30 Dec 2017 02:03:26 -0300 Subject: [PATCH] Extern C blocks (#1352) (#4044) * Add extern C guard blocks to SDK header files #1352 * fixed some extern C blocks in core and libraries --- cores/esp8266/pgmspace.h | 7 ++++--- cores/esp8266/umm_malloc/umm_malloc_cfg.h | 12 ++++++------ libraries/GDBStub/src/internal/gdbstub-entry.h | 4 ++-- tools/sdk/include/at_custom.h | 8 ++++++++ tools/sdk/include/espconn.h | 12 ++++++++++++ tools/sdk/include/espnow.h | 9 +++++++++ tools/sdk/include/ets_sys.h | 8 ++++++++ tools/sdk/include/gpio.h | 8 ++++++++ tools/sdk/include/ip_addr.h | 9 +++++++++ tools/sdk/include/mem.h | 9 +++++++++ tools/sdk/include/mesh.h | 1 + tools/sdk/include/osapi.h | 9 +++++++++ tools/sdk/include/ping.h | 7 +++++++ tools/sdk/include/pwm.h | 9 +++++++++ tools/sdk/include/simple_pair.h | 8 ++++++++ tools/sdk/include/smartconfig.h | 9 +++++++++ tools/sdk/include/sntp.h | 10 ++++++++++ tools/sdk/include/spi_flash.h | 9 +++++++++ tools/sdk/include/upgrade.h | 11 +++++++++++ tools/sdk/include/user_interface.h | 9 +++++++++ tools/sdk/include/wpa2_enterprise.h | 8 ++++++++ 21 files changed, 165 insertions(+), 11 deletions(-) diff --git a/cores/esp8266/pgmspace.h b/cores/esp8266/pgmspace.h index 2e3a71f3a..256c4b99e 100644 --- a/cores/esp8266/pgmspace.h +++ b/cores/esp8266/pgmspace.h @@ -4,9 +4,6 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif #ifdef __ets__ @@ -26,6 +23,10 @@ extern "C" { #endif // __ets__ +#ifdef __cplusplus +extern "C" { +#endif + #define _SFR_BYTE(n) (n) typedef void prog_void; diff --git a/cores/esp8266/umm_malloc/umm_malloc_cfg.h b/cores/esp8266/umm_malloc/umm_malloc_cfg.h index ace0882b4..42856f15c 100644 --- a/cores/esp8266/umm_malloc/umm_malloc_cfg.h +++ b/cores/esp8266/umm_malloc/umm_malloc_cfg.h @@ -6,13 +6,13 @@ #define _UMM_MALLOC_CFG_H #include -#ifdef __cplusplus -extern "C" { -#endif +//#ifdef __cplusplus +//extern "C" { +//#endif #include "c_types.h" -#ifdef __cplusplus -} -#endif +//#ifdef __cplusplus +//} +//#endif /* * There are a number of defines you can set at compile time that affect how * the memory allocator will operate. diff --git a/libraries/GDBStub/src/internal/gdbstub-entry.h b/libraries/GDBStub/src/internal/gdbstub-entry.h index 3e5461e0a..76d16b207 100644 --- a/libraries/GDBStub/src/internal/gdbstub-entry.h +++ b/libraries/GDBStub/src/internal/gdbstub-entry.h @@ -19,7 +19,7 @@ int gdbstub_del_hw_watchpoint(int addr); extern void* gdbstub_do_break_breakpoint_addr; #ifdef __cplusplus -{ +} #endif -#endif \ No newline at end of file +#endif diff --git a/tools/sdk/include/at_custom.h b/tools/sdk/include/at_custom.h index fcf3de61d..79468b9a9 100644 --- a/tools/sdk/include/at_custom.h +++ b/tools/sdk/include/at_custom.h @@ -27,6 +27,10 @@ #include "c_types.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { 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 */ bool at_set_escape_character(uint8 ch); +#ifdef __cplusplus +} +#endif + #endif diff --git a/tools/sdk/include/espconn.h b/tools/sdk/include/espconn.h index 0e8559378..fb0f17007 100644 --- a/tools/sdk/include/espconn.h +++ b/tools/sdk/include/espconn.h @@ -25,6 +25,10 @@ #ifndef __ESPCONN_H__ #define __ESPCONN_H__ +#ifdef __cplusplus +extern "C" { +#endif + typedef sint8 err_t; typedef void *espconn_handle; @@ -742,5 +746,13 @@ void espconn_dns_setserver(uint8 numdns, ip_addr_t *dnsserver); * Returns : dnsserver -- IP address of the DNS server to set *******************************************************************************/ ip_addr_t espconn_dns_getserver(uint8 numdns); + + +#ifdef __cplusplus +} #endif +#endif + + + diff --git a/tools/sdk/include/espnow.h b/tools/sdk/include/espnow.h index 220412c0a..2e1c2dbf6 100644 --- a/tools/sdk/include/espnow.h +++ b/tools/sdk/include/espnow.h @@ -25,6 +25,11 @@ #ifndef __ESPNOW_H__ #define __ESPNOW_H__ + +#ifdef __cplusplus +extern "C" { +#endif + enum esp_now_role { ESP_NOW_ROLE_IDLE = 0, ESP_NOW_ROLE_CONTROLLER, @@ -70,4 +75,8 @@ int esp_now_get_cnt_info(u8 *all_cnt, u8 *encrypt_cnt); int esp_now_set_kok(u8 *key, u8 len); +#ifdef __cplusplus +} +#endif + #endif diff --git a/tools/sdk/include/ets_sys.h b/tools/sdk/include/ets_sys.h index e0da028d6..c4bb25990 100644 --- a/tools/sdk/include/ets_sys.h +++ b/tools/sdk/include/ets_sys.h @@ -29,6 +29,10 @@ #include "eagle_soc.h" #include +#ifdef __cplusplus +extern "C" { +#endif + typedef uint32_t ETSSignal; typedef uint32_t ETSParam; @@ -213,4 +217,8 @@ bool ets_task(ETSTask task, uint8 prio, ETSEvent *queue, uint8 qlen); bool ets_post(uint8 prio, ETSSignal sig, ETSParam par); +#ifdef __cplusplus +} +#endif + #endif /* _ETS_SYS_H */ diff --git a/tools/sdk/include/gpio.h b/tools/sdk/include/gpio.h index 155bbabb8..dd7c78143 100644 --- a/tools/sdk/include/gpio.h +++ b/tools/sdk/include/gpio.h @@ -25,6 +25,10 @@ #ifndef _GPIO_H_ #define _GPIO_H_ +#ifdef __cplusplus +extern "C" { +#endif + #define GPIO_PIN_ADDR(i) (GPIO_PIN0_ADDRESS + i*4) #define GPIO_ID_IS_PIN_REGISTER(reg_id) \ @@ -116,4 +120,8 @@ void gpio_pin_wakeup_disable(); void gpio_pin_intr_state_set(uint32 i, GPIO_INT_TYPE intr_state); +#ifdef __cplusplus +} +#endif + #endif // _GPIO_H_ diff --git a/tools/sdk/include/ip_addr.h b/tools/sdk/include/ip_addr.h index 2f2767e7d..6efc412a8 100644 --- a/tools/sdk/include/ip_addr.h +++ b/tools/sdk/include/ip_addr.h @@ -27,6 +27,10 @@ #include "c_types.h" +#ifdef __cplusplus +extern "C" { +#endif + struct ip_addr { uint32 addr; }; @@ -84,4 +88,9 @@ uint32 ipaddr_addr(const char *cp); #define IPSTR "%d.%d.%d.%d" + +#ifdef __cplusplus +} +#endif + #endif /* __IP_ADDR_H__ */ diff --git a/tools/sdk/include/mem.h b/tools/sdk/include/mem.h index b06c00df3..f404ceda7 100644 --- a/tools/sdk/include/mem.h +++ b/tools/sdk/include/mem.h @@ -25,6 +25,10 @@ #ifndef __MEM_H__ #define __MEM_H__ +#ifdef __cplusplus +extern "C" { +#endif + /* Note: check_memleak_debug_enable is a weak function inside SDK. * please copy following codes to user_main.c. #include "mem.h" @@ -77,5 +81,10 @@ do{\ #endif + +#ifdef __cplusplus +} +#endif + #endif diff --git a/tools/sdk/include/mesh.h b/tools/sdk/include/mesh.h index b55376c39..47a259104 100644 --- a/tools/sdk/include/mesh.h +++ b/tools/sdk/include/mesh.h @@ -27,6 +27,7 @@ #include "ip_addr.h" #include "user_interface.h" #include "espconn.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/tools/sdk/include/osapi.h b/tools/sdk/include/osapi.h index 147e2f53f..19069da97 100644 --- a/tools/sdk/include/osapi.h +++ b/tools/sdk/include/osapi.h @@ -28,6 +28,10 @@ #include #include "user_config.h" +#ifdef __cplusplus +extern "C" { +#endif + #define os_bzero ets_bzero #define os_delay_us ets_delay_us #define os_install_putc1 ets_install_putc1 @@ -77,5 +81,10 @@ extern int os_printf_plus(const char * format, ...) __attribute__ ((format (prin unsigned long os_random(void); int os_get_random(unsigned char *buf, size_t len); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/tools/sdk/include/ping.h b/tools/sdk/include/ping.h index 6537a7a46..9ef72fcb7 100644 --- a/tools/sdk/include/ping.h +++ b/tools/sdk/include/ping.h @@ -25,6 +25,9 @@ #ifndef __PING_H__ #define __PING_H__ +#ifdef __cplusplus +extern "C" { +#endif typedef void (* ping_recv_function)(void* arg, void *pdata); typedef void (* ping_sent_function)(void* arg, void *pdata); @@ -53,4 +56,8 @@ bool ping_start(struct ping_option *ping_opt); bool ping_regist_recv(struct ping_option *ping_opt, ping_recv_function ping_recv); bool ping_regist_sent(struct ping_option *ping_opt, ping_sent_function ping_sent); +#ifdef __cplusplus +} +#endif + #endif /* __PING_H__ */ diff --git a/tools/sdk/include/pwm.h b/tools/sdk/include/pwm.h index eae782f8b..0feec1f7c 100644 --- a/tools/sdk/include/pwm.h +++ b/tools/sdk/include/pwm.h @@ -25,6 +25,10 @@ #ifndef __PWM_H__ #define __PWM_H__ +#ifdef __cplusplus +extern "C" { +#endif + /*pwm.h: function and macro definition of PWM API , driver level */ /*user_light.h: user interface for light API, user level*/ /*user_light_adj: API for color changing and lighting effects, user level*/ @@ -54,5 +58,10 @@ uint32 pwm_get_period(void); uint32 get_pwm_version(void); void set_pwm_debug_en(uint8 print_en); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/tools/sdk/include/simple_pair.h b/tools/sdk/include/simple_pair.h index 801480942..895f0b4d9 100644 --- a/tools/sdk/include/simple_pair.h +++ b/tools/sdk/include/simple_pair.h @@ -25,6 +25,10 @@ #ifndef __SIMPLE_PAIR_H__ #define __SIMPLE_PAIR_H__ +#ifdef __cplusplus +extern "C" { +#endif + typedef enum { SP_ST_STA_FINISH = 0, SP_ST_AP_FINISH = 0, @@ -61,4 +65,8 @@ int simple_pair_set_peer_ref(u8 *peer_mac, u8 *tmp_key, u8 *ex_key); int simple_pair_get_peer_ref(u8 *peer_mac, u8 *tmp_key, u8 *ex_key); +#ifdef __cplusplus +} +#endif + #endif /* __SIMPLE_PAIR_H__ */ diff --git a/tools/sdk/include/smartconfig.h b/tools/sdk/include/smartconfig.h index 6f3802add..c2020a1df 100644 --- a/tools/sdk/include/smartconfig.h +++ b/tools/sdk/include/smartconfig.h @@ -25,6 +25,10 @@ #ifndef __SMARTCONFIG_H__ #define __SMARTCONFIG_H__ +#ifdef __cplusplus +extern "C" { +#endif + typedef enum { SC_STATUS_WAIT = 0, SC_STATUS_FIND_CHANNEL, @@ -47,4 +51,9 @@ bool smartconfig_stop(void); bool esptouch_set_timeout(uint8 time_s); //15s~255s, offset:45s bool smartconfig_set_type(sc_type type); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/tools/sdk/include/sntp.h b/tools/sdk/include/sntp.h index db0274895..18dd0f531 100644 --- a/tools/sdk/include/sntp.h +++ b/tools/sdk/include/sntp.h @@ -7,6 +7,11 @@ #else #include "ip_addr.h" #endif + +#ifdef __cplusplus +extern "C" { +#endif + /** * get the seconds since Jan 01, 1970, 00:00 (GMT + 8) */ @@ -65,4 +70,9 @@ char *sntp_getservername(unsigned char idx); #define sntp_servermode_dhcp(x) + +#ifdef __cplusplus +} +#endif + #endif diff --git a/tools/sdk/include/spi_flash.h b/tools/sdk/include/spi_flash.h index 6661635ea..00f8a08b7 100644 --- a/tools/sdk/include/spi_flash.h +++ b/tools/sdk/include/spi_flash.h @@ -25,6 +25,10 @@ #ifndef SPI_FLASH_H #define SPI_FLASH_H +#ifdef __cplusplus +extern "C" { +#endif + typedef enum { SPI_FLASH_RESULT_OK, SPI_FLASH_RESULT_ERR, @@ -60,4 +64,9 @@ void spi_flash_set_read_func(user_spi_flash_read read); bool spi_flash_erase_protect_enable(void); bool spi_flash_erase_protect_disable(void); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/tools/sdk/include/upgrade.h b/tools/sdk/include/upgrade.h index e7e69681b..6c88f9a04 100644 --- a/tools/sdk/include/upgrade.h +++ b/tools/sdk/include/upgrade.h @@ -25,6 +25,11 @@ #ifndef __UPGRADE_H__ #define __UPGRADE_H__ +#ifdef __cplusplus +extern "C" { +#endif + + #define SPI_FLASH_SEC_SIZE 4096 #define LIMIT_ERASE_SIZE 0x10000 @@ -71,4 +76,10 @@ bool system_upgrade_start_ssl(struct upgrade_server_info *server); // not suppor #else bool system_upgrade_start(struct upgrade_server_info *server); #endif + + +#ifdef __cplusplus +} +#endif + #endif diff --git a/tools/sdk/include/user_interface.h b/tools/sdk/include/user_interface.h index 01374fcfc..f94b95ec9 100644 --- a/tools/sdk/include/user_interface.h +++ b/tools/sdk/include/user_interface.h @@ -37,6 +37,10 @@ #include "spi_flash.h" #include "gpio.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifndef MAC2STR #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" @@ -651,4 +655,9 @@ void wifi_disable_gpio_wakeup(void); void uart_div_modify(uint8 uart_no, uint32 DivLatchValue); +#ifdef __cplusplus +} +#endif + + #endif diff --git a/tools/sdk/include/wpa2_enterprise.h b/tools/sdk/include/wpa2_enterprise.h index 9bd0ba516..bfbfdf49c 100644 --- a/tools/sdk/include/wpa2_enterprise.h +++ b/tools/sdk/include/wpa2_enterprise.h @@ -25,6 +25,10 @@ #ifndef __WPA2_ENTERPRISE_H__ #define __WPA2_ENTERPRISE_H__ +#ifdef __cplusplus +extern "C" { +#endif + typedef long os_time_t; struct os_time { @@ -62,4 +66,8 @@ bool wifi_station_get_enterprise_disable_time_check(void); void wpa2_enterprise_set_user_get_time(get_time_func_t cb); +#ifdef __cplusplus +} +#endif + #endif /* __WPA2_ENTERPRISE_H__ */