extern "C" status_t
时间: 2023-11-10 14:07:23 浏览: 43
extern "C"是一种C++的语法,它可以告诉编译器按照C语言的规则来编译某一段代码。通常情况下,C++会对函数名进行名称修饰,但是使用extern "C"可以避免这种情况,使得C++代码可以调用C语言的函数。而status_t是一个自定义的数据类型,它可能表示某种状态或结果。在这里,我们无法确定status_t的具体含义,因为它没有被定义或引用。引用中提到,如果将test_extern_c.h中的extern "C" {}所在的那几行注释掉,可能会导致编译错误或链接错误。
相关问题
20181445-2.1.c: In function ‘main’: 20181445-2.1.c:90:29: warning: passing argument 2 of ‘waitpid’ from incompatible pointer type [-Wincompatible-pointer-types] 90 | waitpid(pid,&stat,0); | ^~~~~ | | | int (*)(const char * restrict, struct stat * restrict) In file included from 20181445-2.1.c:7: /usr/include/x86_64-linux-gnu/sys/wait.h:111:45: note: expected ‘int *’ but argument is of type ‘int (*)(const char * restrict, struct stat * restrict)’ 111 | extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
这个编译警告是因为waitpid函数的第二个参数应该是一个指向int类型的指针,但是你传递的参数类型是一个指向函数的指针,因此参数类型不兼容。你需要修改代码,将第二个参数&stat改为指向int类型的指针变量,例如:
```
int status;
waitpid(pid, &status, 0);
```
这个修改会将status变量的地址传递给waitpid函数,使得waitpid函数能够在子进程退出时将子进程的状态信息存储到该变量中。这样就能解决编译警告的问题。
#ifndef _ESP8266_H_ #define _ESP8266_H_ #include "main.h" //C¿â #include <stdarg.h> #include <stdlib.h> #define SSID "WIFI" #define PASS "123456789" #define ProductKey "a1wDiNYFwS5" #define DeviceName "PillsCar" #define ClientId "123|securemode=3\\,signmethod=hmacsha1|" #define Password "6940E27041D06C047F31951986F328A11267240C" #define mqttHostUrl "a1wDiNYFwS5.iot-as-mqtt.cn-shanghai.aliyuncs.com" #define port "1883" #define Huart_wifi huart2 #define REV_OK 0 //½ÓÊÕÍê³É±êÖ¾ #define REV_WAIT 1 //½ÓÊÕδÍê³É±êÖ¾ #define DelayXms(x) HAL_Delay(x) extern unsigned char ESP8266_buf[1024]; extern unsigned short ESP8266_cnt; extern uint8_t uartwifi_value; //´®¿Ú2½ÓÊÕ»º´æ±äÁ¿ typedef struct{ //ʱ¼ä½á¹¹Ìå uint16_t year; uint8_t month; uint8_t day; uint8_t week; uint8_t hour; uint8_t minute; uint8_t second; }Time_Get; void ESP8266_init(void); //Á¬ÉÏÍøÂçÔò²»¼ÌÐøÁ¬½ÓÁË void Ali_MQTT_Publish(void); //Éϱ¨ÏûÏ¢ ½¨Òé1sÉÏ´«Ò»´ÎÊý¾Ý void Ali_MQTT_Publish_1(void); void Ali_MQTT_Publish_3(void); void Ali_MQTT_Publish_4(void); void Ali_MQTT_Publish_mode(void); void Ali_MQTT_Recevie(void); //½ÓÊÕÏûÏ¢ _Bool ESP8266_Status(void); //1-Á¬½Ó״̬ 0-¶Ï¿ª×´Ì¬ Time_Get ESP8266_Get_Time(void); //´®¿Ú»Øµ÷º¯ÊýʹÓ÷½·¨ //void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) //{ // if(huart->Instance == Huart_wifi.Instance)//´®¿Ú´¥·¢ÖÐ¶Ï // { // if(huart->Instance == Huart_wifi.Instance)//´®¿Ú´¥·¢ // { // HAL_UART_Receive_IT(&Huart_wifi, &uartwifi_value, 1); // if(ESP8266_cnt >= sizeof(ESP8266_buf)) ESP8266_cnt = 0; //·ÀÖ¹´®¿Ú±»Ë¢±¬ // ESP8266_buf[ESP8266_cnt++] = uartwifi_value; // } // } //} #endif
这是一个 ESP8266 模块的驱动程序,用于与阿里云的 MQTT 服务器进行通信。其中包含了 ESP8266 的初始化函数、MQTT 的发布和接收函数,以及获取时间的函数等。此外,还定义了一些常量,如 Wi-Fi 的 SSID 和密码、阿里云 MQTT 服务器的相关信息等。这个程序是通过串口与 ESP8266 模块进行通信的,其中的 HAL_UART_RxCpltCallback 函数是一个回调函数,用于在接收到数据时进行处理。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)