'FILE_DEVICE_UNKNOWN' : undeclared identifier

本文介绍了解决使用DeviceIoControl函数时遇到的编译错误的方法,通过包含winioctl.h头文件成功解决了未声明标识符的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

GPIO之FILE_DEVICE_UNKNOWN
2010-07-26 21:50

在使用DeviceIoControl函数的时候,编译总是出现下面的错误:

1>.\GPIOCTL_API.cpp(73) : error C2065: 'FILE_DEVICE_UNKNOWN' : undeclared identifier
1>.\GPIOCTL_API.cpp(73) : error C2065: 'METHOD_BUFFERED' : undeclared identifier
1>.\GPIOCTL_API.cpp(73) : error C2065: 'FILE_ANY_ACCESS' : undeclared identifier
1>.\GPIOCTL_API.cpp(73) : error C3861: 'CTL_CODE': identifier not found

最后在前面加上:

#include <winioctl.h>

就解决了。

还不知道为什么,,,,

转自:http://hi.baidu.com/xiaosan5871/blog/item/8ddf153318315df51b4cff27.html
D:/esp32_C3/vendor_0.1.1/main/main.c: In function 'optimize_scan_parameters': D:/esp32_C3/vendor_0.1.1/main/main.c:233:5: error: unknown type name 'esp_ble_scan_params_t' 233 | esp_ble_scan_params_t scan_params = { | ^~~~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:234:9: error: field name not in record or union initializer 234 | .scan_type = BLE_SCAN_TYPE_ACTIVE, | ^ D:/esp32_C3/vendor_0.1.1/main/main.c:234:9: note: (near initialization for 'scan_params') D:/esp32_C3/vendor_0.1.1/main/main.c:234:22: error: 'BLE_SCAN_TYPE_ACTIVE' undeclared (first use in this function) 234 | .scan_type = BLE_SCAN_TYPE_ACTIVE, | ^~~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:234:22: note: each undeclared identifier is reported only once for each function it appears in D:/esp32_C3/vendor_0.1.1/main/main.c:235:9: error: field name not in record or union initializer 235 | .own_addr_type = BLE_ADDR_TYPE_PUBLIC, | ^ D:/esp32_C3/vendor_0.1.1/main/main.c:235:9: note: (near initialization for 'scan_params') D:/esp32_C3/vendor_0.1.1/main/main.c:235:26: error: 'BLE_ADDR_TYPE_PUBLIC' undeclared (first use in this function) 235 | .own_addr_type = BLE_ADDR_TYPE_PUBLIC, | ^~~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:235:26: warning: excess elements in scalar initializer D:/esp32_C3/vendor_0.1.1/main/main.c:235:26: note: (near initialization for 'scan_params') D:/esp32_C3/vendor_0.1.1/main/main.c:236:9: error: field name not in record or union initializer 236 | .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, | ^ D:/esp32_C3/vendor_0.1.1/main/main.c:236:9: note: (near initialization for 'scan_params') D:/esp32_C3/vendor_0.1.1/main/main.c:236:31: error: 'BLE_SCAN_FILTER_ALLOW_ALL' undeclared (first use in this function) 236 | .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, | ^~~~~~~~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:236:31: warning: excess elements in scalar initializer D:/esp32_C3/vendor_0.1.1/main/main.c:236:31: note: (near initialization for 'scan_params') D:/esp32_C3/vendor_0.1.1/main/main.c:237:9: error: field name not in record or union initializer 237 | .scan_interval = 0x60, // 鏇寸煭鐨勬壂鎻忛棿闅?(60ms) | ^ D:/esp32_C3/vendor_0.1.1/main/main.c:237:9: note: (near initialization for 'scan_params') D:/esp32_C3/vendor_0.1.1/main/main.c:237:26: warning: excess elements in scalar initializer 237 | .scan_interval = 0x60, // 鏇寸煭鐨勬壂鎻忛棿闅?(60ms) | ^~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:237:26: note: (near initialization for 'scan_params') D:/esp32_C3/vendor_0.1.1/main/main.c:238:9: error: field name not in record or union initializer 238 | .scan_window = 0x30, // 鏇撮暱鐨勬壂鎻忕獥鍙?(30ms) | ^ D:/esp32_C3/vendor_0.1.1/main/main.c:238:9: note: (near initialization for 'scan_params') D:/esp32_C3/vendor_0.1.1/main/main.c:238:24: warning: excess elements in scalar initializer 238 | .scan_window = 0x30, // 鏇撮暱鐨勬壂鎻忕獥鍙?(30ms) | ^~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:238:24: note: (near initialization for 'scan_params') D:/esp32_C3/vendor_0.1.1/main/main.c:239:9: error: field name not in record or union initializer 239 | .scan_duplicate = BLE_SCAN_DUPLICATE_DISABLE | ^ D:/esp32_C3/vendor_0.1.1/main/main.c:239:9: note: (near initialization for 'scan_params') D:/esp32_C3/vendor_0.1.1/main/main.c:239:27: error: 'BLE_SCAN_DUPLICATE_DISABLE' undeclared (first use in this function) 239 | .scan_duplicate = BLE_SCAN_DUPLICATE_DISABLE | ^~~~~~~~~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:239:27: warning: excess elements in scalar initializer D:/esp32_C3/vendor_0.1.1/main/main.c:239:27: note: (near initialization for 'scan_params') D:/esp32_C3/vendor_0.1.1/main/main.c:242:21: error: implicit declaration of function 'esp_ble_gap_set_scan_params' [-Wimplicit-function-declaration] 242 | esp_err_t err = esp_ble_gap_set_scan_params(&scan_params); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from D:/esp32_C3/vendor_0.1.1/main/main.c:8: D:/esp32_C3/vendor_0.1.1/main/main.c:247:28: error: request for member 'scan_interval' in something not a structure or union 247 | scan_params.scan_interval, scan_params.scan_window); | ^ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:182:137: note: in definition of macro 'ESP_LOG_LEVEL' 182 | if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~~ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:114:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 114 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:246:9: note: in expansion of macro 'ESP_LOGI' 246 | ESP_LOGI(TAG, "鎵弿鍙傛暟浼樺寲瀹屾垚: interval=0x%X, window=0x%X", | ^~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:247:55: error: request for member 'scan_window' in something not a structure or union 247 | scan_params.scan_interval, scan_params.scan_window); | ^ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:182:137: note: in definition of macro 'ESP_LOG_LEVEL' 182 | if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~~ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:114:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 114 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:246:9: note: in expansion of macro 'ESP_LOGI' 246 | ESP_LOGI(TAG, "鎵弿鍙傛暟浼樺寲瀹屾垚: interval=0x%X, window=0x%X", | ^~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:247:28: error: request for member 'scan_interval' in something not a structure or union 247 | scan_params.scan_interval, scan_params.scan_window); | ^ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:183:137: note: in definition of macro 'ESP_LOG_LEVEL' 183 | else if (level==ESP_LOG_WARN ) { esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~~ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:114:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 114 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:246:9: note: in expansion of macro 'ESP_LOGI' 246 | ESP_LOGI(TAG, "鎵弿鍙傛暟浼樺寲瀹屾垚: interval=0x%X, window=0x%X", | ^~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:247:55: error: request for member 'scan_window' in something not a structure or union 247 | scan_params.scan_interval, scan_params.scan_window); | ^ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:183:137: note: in definition of macro 'ESP_LOG_LEVEL' 183 | else if (level==ESP_LOG_WARN ) { esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~~ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:114:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 114 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:246:9: note: in expansion of macro 'ESP_LOGI' 246 | ESP_LOGI(TAG, "鎵弿鍙傛暟浼樺寲瀹屾垚: interval=0x%X, window=0x%X", | ^~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:247:28: error: request for member 'scan_interval' in something not a structure or union 247 | scan_params.scan_interval, scan_params.scan_window); | ^ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:184:137: note: in definition of macro 'ESP_LOG_LEVEL' 184 | else if (level==ESP_LOG_DEBUG ) { esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~~ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:114:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 114 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:246:9: note: in expansion of macro 'ESP_LOGI' 246 | ESP_LOGI(TAG, "鎵弿鍙傛暟浼樺寲瀹屾垚: interval=0x%X, window=0x%X", | ^~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:247:55: error: request for member 'scan_window' in something not a structure or union 247 | scan_params.scan_interval, scan_params.scan_window); | ^ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:184:137: note: in definition of macro 'ESP_LOG_LEVEL' 184 | else if (level==ESP_LOG_DEBUG ) { esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~~ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:114:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 114 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:246:9: note: in expansion of macro 'ESP_LOGI' 246 | ESP_LOGI(TAG, "鎵弿鍙傛暟浼樺寲瀹屾垚: interval=0x%X, window=0x%X", | ^~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:247:28: error: request for member 'scan_interval' in something not a structure or union 247 | scan_params.scan_interval, scan_params.scan_window); | ^ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:185:137: note: in definition of macro 'ESP_LOG_LEVEL' 185 | else if (level==ESP_LOG_VERBOSE ) { esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~~ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:114:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 114 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:246:9: note: in expansion of macro 'ESP_LOGI' 246 | ESP_LOGI(TAG, "鎵弿鍙傛暟浼樺寲瀹屾垚: interval=0x%X, window=0x%X", | ^~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:247:55: error: request for member 'scan_window' in something not a structure or union 247 | scan_params.scan_interval, scan_params.scan_window); | ^ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:185:137: note: in definition of macro 'ESP_LOG_LEVEL' 185 | else if (level==ESP_LOG_VERBOSE ) { esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~~ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:114:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 114 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:246:9: note: in expansion of macro 'ESP_LOGI' 246 | ESP_LOGI(TAG, "鎵弿鍙傛暟浼樺寲瀹屾垚: interval=0x%X, window=0x%X", | ^~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:247:28: error: request for member 'scan_interval' in something not a structure or union 247 | scan_params.scan_interval, scan_params.scan_window); | ^ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:186:137: note: in definition of macro 'ESP_LOG_LEVEL' 186 | else { esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~~ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:114:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 114 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:246:9: note: in expansion of macro 'ESP_LOGI' 246 | ESP_LOGI(TAG, "鎵弿鍙傛暟浼樺寲瀹屾垚: interval=0x%X, window=0x%X", | ^~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:247:55: error: request for member 'scan_window' in something not a structure or union 247 | scan_params.scan_interval, scan_params.scan_window); | ^ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:186:137: note: in definition of macro 'ESP_LOG_LEVEL' 186 | else { esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~~ E:/espidf/v5.4.1/esp-idf/components/log/include/esp_log.h:114:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 114 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:246:9: note: in expansion of macro 'ESP_LOGI' 246 | ESP_LOGI(TAG, "鎵弿鍙傛暟浼樺寲瀹屾垚: interval=0x%X, window=0x%X", | ^~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c: In function 'switch_device_role': D:/esp32_C3/vendor_0.1.1/main/main.c:528:41: error: 'example_ble_mesh_provisioning_cb' undeclared (first use in this function) 528 | esp_ble_mesh_register_prov_callback(example_ble_mesh_provisioning_cb); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c:529:49: error: 'example_ble_mesh_custom_model_cb' undeclared (first use in this function) 529 | esp_ble_mesh_register_custom_model_callback(example_ble_mesh_custom_model_cb); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c: In function 'example_ble_mesh_provisioning_cb': D:/esp32_C3/vendor_0.1.1/main/main.c:642:31: error: implicit declaration of function 'esp_ble_gap_get_rssi' [-Wimplicit-function-declaration] 642 | int8_t rssi = esp_ble_gap_get_rssi(param->provisioner_recv_unprov_adv_pkt.addr); | ^~~~~~~~~~~~~~~~~~~~ D:/esp32_C3/vendor_0.1.1/main/main.c: In function 'ble_mesh_init': D:/esp32_C3/vendor_0.1.1/main/main.c:984:9: error: implicit declaration of function 'esp_\U00006781_mesh_node_prov_enable'; did you mean 'esp_ble_mesh_node_prov_enable'? [-Wimplicit-function-declaration] 984 | esp_鏋乢mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ | esp_ble_mesh_node_prov_enable D:/esp32_C3/vendor_0.1.1/main/main.c: At top level: D:/esp32_C3/vendor_0.1.1/main/main.c:292:18: warning: 'prov_complete' defined but not used [-Wunused-function] 292 | static esp_err_t prov_complete(uint16_t node_index, cninja: build stopped: subcommand failed. * 终端进程“e:\espidf\espressif\tools\ninja\1.12.1\ninja.EXE”已终止,退出代码: 1。
07-12
root@ubuntu:/home/wuju/project/did-zkp-gnark# make go mod tidy go build -buildmode=c-archive -o zkproof.a zkproof.go gcc -o client client.c zkproof.a \ -I/home/wuju/xquic/include -I. \ -L/home/wuju/xquic/build -L/home/wuju/xquic/third_party/boringssl/build \ -lxquic-static -lssl -lcrypto -lpthread -lm -lstdc++ client.c: In function ‘main’: client.c:61:28: error: too few arguments to function ‘xqc_engine_create’ xqc_engine_t *engine = xqc_engine_create(XQC_ENGINE_CLIENT, NULL, NULL, NULL); ^~~~~~~~~~~~~~~~~ In file included from client.c:9:0: /home/wuju/xquic/include/xquic/xquic.h:1613:15: note: declared here xqc_engine_t *xqc_engine_create(xqc_engine_type_t engine_type, ^~~~~~~~~~~~~~~~~ client.c:77:30: warning: implicit declaration of function ‘xqc_engine_connect’; did you mean ‘xqc_engine_create’? [-Wimplicit-function-declaration] xqc_connection_t *conn = xqc_engine_connect( ^~~~~~~~~~~~~~~~~~ xqc_engine_create client.c:77:30: warning: initialization makes pointer from integer without a cast [-Wint-conversion] client.c:89:28: warning: implicit declaration of function ‘xqc_conn_create_stream’; did you mean ‘xqc_conn_create_path’? [-Wimplicit-function-declaration] xqc_stream_t *stream = xqc_conn_create_stream(conn, XQC_STREAM_BIDI, 0); ^~~~~~~~~~~~~~~~~~~~~~ xqc_conn_create_path client.c:89:28: warning: initialization makes pointer from integer without a cast [-Wint-conversion] client.c:104:68: error: ‘XQC_FIN’ undeclared (first use in this function); did you mean ‘MSG_FIN’? xqc_stream_send(stream, (char*)&header, sizeof(MessageHeader), XQC_FIN); ^~~~~~~ MSG_FIN client.c:104:68: note: each undeclared identifier is reported only once for each function it appears in Makefile:16: recipe for target 'build' failed make: *** [build] Error 1
最新发布
07-25
[OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c: In function 'gps_init': [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:115:5: error: unknown type name 'hi_uart_attribute'; did you mean '__has_attribute'? [OHOS ERROR] hi_uart_attribute config = { [OHOS ERROR] ^~~~~~~~~~~~~~~~~ [OHOS ERROR] __has_attribute [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:116:9: error: field name not in record or union initializer [OHOS ERROR] .baud_rate = 9600, // NEO-6M默认波特率 [OHOS ERROR] ^ [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:116:9: note: (near initialization for 'config') [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:117:9: error: field name not in record or union initializer [OHOS ERROR] .data_bits = HI_UART_DATA_BIT_8, // 8位数据位 [OHOS ERROR] ^ [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:117:9: note: (near initialization for 'config') [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:117:22: error: 'HI_UART_DATA_BIT_8' undeclared (first use in this function); did you mean 'HI_ERR_DMA_BUSY'? [OHOS ERROR] .data_bits = HI_UART_DATA_BIT_8, // 8位数据位 [OHOS ERROR] ^~~~~~~~~~~~~~~~~~ [OHOS ERROR] HI_ERR_DMA_BUSY [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:117:22: note: each undeclared identifier is reported only once for each function it appears in [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:117:22: warning: excess elements in scalar initializer [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:117:22: note: (near initialization for 'config') [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:118:9: error: field name not in record or union initializer [OHOS ERROR] .stop_bits = HI_UART_STOP_BIT_1, // 1位停止位 [OHOS ERROR] ^ [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:118:9: note: (near initialization for 'config') [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:118:22: error: 'HI_UART_STOP_BIT_1' undeclared (first use in this function); did you mean 'HI_UART_DATA_BIT_8'? [OHOS ERROR] .stop_bits = HI_UART_STOP_BIT_1, // 1位停止位 [OHOS ERROR] ^~~~~~~~~~~~~~~~~~ [OHOS ERROR] HI_UART_DATA_BIT_8 [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:118:22: warning: excess elements in scalar initializer [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:118:22: note: (near initialization for 'config') [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:119:9: error: field name not in record or union initializer [OHOS ERROR] .parity = HI_UART_PARITY_NONE, // 无校验 [OHOS ERROR] ^ [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:119:9: note: (near initialization for 'config') [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:119:19: error: 'HI_UART_PARITY_NONE' undeclared (first use in this function); did you mean 'HI_UART_DATA_BIT_8'? [OHOS ERROR] .parity = HI_UART_PARITY_NONE, // 无校验 [OHOS ERROR] ^~~~~~~~~~~~~~~~~~~ [OHOS ERROR] HI_UART_DATA_BIT_8 [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:119:19: warning: excess elements in scalar initializer [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:119:19: note: (near initialization for 'config') [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:120:9: error: field name not in record or union initializer [OHOS ERROR] .fifo_enable = HI_TRUE // 启用FIFO [OHOS ERROR] ^ [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:120:9: note: (near initialization for 'config') [OHOS ERROR] In file included from ../../../device/hisilicon/hispark_pegasus/sdk_liteos/include/hi_io.h:26:0, [OHOS ERROR] from ../../../vendor/pzkj/pz_hi3861/common/bsp/include/bsp_gps.h:6, [OHOS ERROR] from ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:1: [OHOS ERROR] ../../../device/hisilicon/hispark_pegasus/sdk_liteos/include/hi_types_base.h:284:26: warning: excess elements in scalar initializer [OHOS ERROR] #define HI_TRUE 1 [OHOS ERROR] ^ [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:120:24: note: in expansion of macro 'HI_TRUE' [OHOS ERROR] .fifo_enable = HI_TRUE // 启用FIFO [OHOS ERROR] ^~~~~~~ [OHOS ERROR] ../../../device/hisilicon/hispark_pegasus/sdk_liteos/include/hi_types_base.h:284:26: note: (near initialization for 'config') [OHOS ERROR] #define HI_TRUE 1 [OHOS ERROR] ^ [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:120:24: note: in expansion of macro 'HI_TRUE' [OHOS ERROR] .fifo_enable = HI_TRUE // 启用FIFO [OHOS ERROR] ^~~~~~~ [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:124:18: warning: implicit declaration of function 'hi_uart_init'; did you mean 'uart0_init'? [-Wimplicit-function-declaration] [OHOS ERROR] hi_u32 ret = hi_uart_init(HI_UART_IDX_2, &config); [OHOS ERROR] ^~~~~~~~~~~~ [OHOS ERROR] uart0_init [OHOS ERROR] ../../../vendor/pzkj/pz_hi3861/common/bsp/src/bsp_gps.c:124:31: error: 'HI_UART_IDX_2' undeclared (first use in this function); did you mean 'HI_GPIO_IDX_2'? [OHOS ERROR] hi_u32 ret = hi_uart_init(HI_UART_IDX_2, &config); [OHOS ERROR] ^~~~~~~~~~~~~ [OHOS ERROR] HI_GPIO_IDX_2 [OHOS ERROR] you can check build log in D:\hi3861\hi3861_hdu_iot_application\src\out\hispark_pegasus\wifiiot_hispark_pegasus\build.log [OHOS ERROR] command: "D:\hi3861\hi3861_hdu_iot_application\src\prebuilts\build-tools\win64-x64\bin\ninja.exe -w dupbuild=warn -C D:\hi3861\hi3861_hdu_iot_application\src\out\hispark_pegasus\wifiiot_hispark_pegasus" failed [OHOS ERROR] return code: 1 [OHOS ERROR] execution path: D:\hi3861\hi3861_hdu_iot_application\src scons: *** [src\out\hispark_pegasus\wifiiot_hispark_pegasus\target.elf] Error -1请根据该错误对VSCODE以下代码进行修改#ifndef BSP__GPS_H__ #define BSP__GPS_H__ #include "cmsis_os2.h" #include "hi_io.h" #include "hi_gpio.h" #include <stdio.h> #include <string.h> #include "bsp_uart.h" #include "hi_errno.h" // GPS 数据结构定义 typedef struct { float longitude; // 经度 (度) float latitude; // 纬度 (度) char nshemi; // 北纬/南纬 (N/S) char ewhemi; // 东经/西经 (E/W) struct { uint8_t hour; // UTC 小时 uint8_t min; // UTC 分钟 uint8_t sec; // UTC 秒 } utc; uint8_t fixmode; // 定位模式 uint8_t posslnum; // 参与定位的卫星数 float altitude; // 海拔高度 (米) } nmea_msg; // 定义UART2引脚配置 #define GPS_UART_IDX HI_UART_IDX_2 #define GPS_BAUDRATE 9600 // NEO-6M默认波特率 // 函数声明 void gps_init(void); void gps_parse_nmea(nmea_msg *gps, const char *buf); void gps_show_data(const nmea_msg *gps); #endif#include "bsp_gps.h" #include <stdlib.h> #include "bsp_uart.h" // 添加必要的UART头文件 // 查找逗号位置 // 计算m的n次方 static uint32_t NMEA_Pow(uint8_t m, uint8_t n) { uint32_t result = 1; while (n--) result *= m; return result; } // 查找逗号位置(修改为接受const指针) uint8_t nmea_comma_pos(const uint8_t *buf, uint8_t cx) { const uint8_t *p = buf; while (cx) { if (*buf == '*' || *buf < ' ' || *buf > 'z') return 0xFF; // 错误终止符 if (*buf == ',') cx--; buf++; } return buf - p; } // 字符串转数字(修改为接受const指针) int nmea_str2num(const uint8_t *buf, uint8_t *dx) { const uint8_t *p = buf; uint32_t ires = 0, fres = 0; uint8_t ilen = 0, flen = 0, i; uint8_t mask = 0; int res; while (1) { if (*p == '-') { mask |= 0x02; p++; } // 负数标记 if (*p == ',' || *p == '*') break; // 结束符 if (*p == '.') { mask |= 0x01; p++; } // 小数点 else if (*p > '9' || *p < '0') { // 非法字符 ilen = 0; flen = 0; break; } if (mask & 0x01) flen++; else ilen++; p++; } if (mask & 0x02) buf++; // 跳过负号 for (i = 0; i < ilen; i++) // 整数部分 ires += NMEA_Pow(10, ilen - 1 - i) * (buf[i] - '0'); if (flen > 5) flen = 5; // 最多5位小数 if (dx) *dx = flen; // 安全处理空指针 for (i = 0; i < flen; i++) // 小数部分 fres += NMEA_Pow(10, flen - 1 - i) * (buf[ilen + 1 + i] - '0'); res = ires * NMEA_Pow(10, flen) + fres; if (mask & 0x02) res = -res; return res; } // 解析 GPRMC 语句 static void parse_gprmc(nmea_msg *gps, const char *buf) { const char *p = strstr(buf, "GPRMC"); if (!p) return; // 显式类型转换解决警告(函数参数已改为const uint8_t*) uint8_t pos = nmea_comma_pos((const uint8_t *)p, 1); // UTC 时间 if (pos != 0xFF) { uint32_t time = nmea_str2num((const uint8_t *)(p + pos), NULL); gps->utc.hour = time / 10000; gps->utc.min = (time % 10000) / 100; gps->utc.sec = time % 100; } pos = nmea_comma_pos((const uint8_t *)p, 3); // 纬度 if (pos != 0xFF) { float lat = nmea_str2num((const uint8_t *)(p + pos), NULL) / 100000.0f; gps->latitude = (int)(lat / 100) + (lat - (int)(lat / 100) * 100) / 60.0f; } pos = nmea_comma_pos((const uint8_t *)p, 4); // 纬度半球 if (pos != 0xFF) gps->nshemi = *(p + pos); pos = nmea_comma_pos((const uint8_t *)p, 5); // 经度 if (pos != 0xFF) { float lon = nmea_str2num((const uint8_t *)(p + pos), NULL) / 100000.0f; gps->longitude = (int)(lon / 100) + (lon - (int)(lon / 100) * 100) / 60.0f; } pos = nmea_comma_pos((const uint8_t *)p, 6); // 经度半球 if (pos != 0xFF) gps->ewhemi = *(p + pos); } // 主解析函数 void gps_parse_nmea(nmea_msg *gps, const char *buf) { if (strstr(buf, "$GPRMC")) parse_gprmc(gps, buf); // 修正:移除多余空格 // 可扩展其他语句解析 (如GPGGA, GPGSA等) } void gps_init(void) { // 初始化GPIO子系统 (必须首先调用) hi_gpio_init(); // ===== 配置TX引脚 (GPIO11 - 输出) ===== hi_io_set_pull(HI_IO_NAME_GPIO_11, HI_IO_PULL_UP); // 上拉模式 hi_io_set_func(HI_IO_NAME_GPIO_11, HI_IO_FUNC_GPIO_11_UART2_TXD); // UART TX功能 hi_gpio_set_dir(HI_IO_NAME_GPIO_11, HI_GPIO_DIR_OUT); // 输出方向 // ===== 配置RX引脚 (GPIO12 - 输入) ===== hi_io_set_pull(HI_IO_NAME_GPIO_12, HI_IO_PULL_NONE); // 浮空模式(推荐) hi_io_set_func(HI_IO_NAME_GPIO_12, HI_IO_FUNC_GPIO_12_UART2_RXD); // UART RX功能 hi_gpio_set_dir(HI_IO_NAME_GPIO_12, HI_GPIO_DIR_IN); // 输入方向 // ===== UART参数配置 ===== hi_uart_attribute config = { .baud_rate = 9600, // NEO-6M默认波特率 .data_bits = HI_UART_DATA_BIT_8, // 8位数据位 .stop_bits = HI_UART_STOP_BIT_1, // 1位停止位 .parity = HI_UART_PARITY_NONE, // 无校验 .fifo_enable = HI_TRUE // 启用FIFO }; // 初始化UART2 hi_u32 ret = hi_uart_init(HI_UART_IDX_2, &config); if (ret != HI_ERR_SUCCESS) { printf("GPS UART init failed! Error: 0x%X\n", ret); } } // 显示GPS数据 void gps_show_data(const nmea_msg *gps) { printf("Longitude: %.5f%c\n", gps->longitude, gps->ewhemi); printf("Latitude: %.5f%c\n", gps->latitude, gps->nshemi); printf("UTC Time: %02d:%02d:%02d\n", gps->utc.hour, gps->utc.min, gps->utc.sec); printf("Satellites: %d\n", gps->posslnum); printf("Altitude: %.1fm\n", gps->altitude); }
07-07
19:49:48 **** Incremental Build of configuration Debug for project zhongduan **** make -j20 all arm-none-eabi-gcc "../icode/menu/menu.c" -mcpu=cortex-m3 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32F103xB -c -I../Core/Inc -I../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I../Drivers/STM32F1xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"icode/menu/menu.d" -MT"icode/menu/menu.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "icode/menu/menu.o" ../icode/menu/menu.c: In function 'save_params_to_flash': ../icode/menu/menu.c:51:21: error: 'EH1' undeclared (first use in this function) 51 | sysParams.EH1 = EH1; | ^~~ ../icode/menu/menu.c:51:21: note: each undeclared identifier is reported only once for each function it appears in ../icode/menu/menu.c:52:21: error: 'EH2' undeclared (first use in this function) 52 | sysParams.EH2 = EH2; | ^~~ ../icode/menu/menu.c:53:31: error: 'FUSE1_ON_TIME' undeclared (first use in this function) 53 | sysParams.FUSE1_ON_TIME = FUSE1_ON_TIME; | ^~~~~~~~~~~~~ ../icode/menu/menu.c:54:31: error: 'FUSE2_ON_TIME' undeclared (first use in this function) 54 | sysParams.FUSE2_ON_TIME = FUSE2_ON_TIME; | ^~~~~~~~~~~~~ ../icode/menu/menu.c: In function 'load_params_from_flash': ../icode/menu/menu.c:97:5: error: 'EH1' undeclared (first use in this function) 97 | EH1 = sysParams.EH1; | ^~~ ../icode/menu/menu.c:98:5: error: 'EH2' undeclared (first use in this function) 98 | EH2 = sysParams.EH2; | ^~~ ../icode/menu/menu.c:99:5: error: 'FUSE1_ON_TIME' undeclared (first use in this function) 99 | FUSE1_ON_TIME = sysParams.FUSE1_ON_TIME; | ^~~~~~~~~~~~~ ../icode/menu/menu.c:100:5: error: 'FUSE2_ON_TIME' undeclared (first use in this function) 100 | FUSE2_ON_TIME = sysParams.FUSE2_ON_TIME; | ^~~~~~~~~~~~~ ../icode/menu/menu.c: In function 'init_params_system': ../icode/menu/menu.c:112:9: error: 'EH1' undeclared (first use in this function) 112 | EH1 = 0; | ^~~ ../icode/menu/menu.c:113:9: error: 'EH2' undeclared (first use in this function) 113 | EH2 = 0; | ^~~ ../icode/menu/menu.c:114:9: error: 'FUSE1_ON_TIME' undeclared (first use in this function) 114 | FUSE1_ON_TIME = 0; | ^~~~~~~~~~~~~ ../icode/menu/menu.c:115:9: error: 'FUSE2_ON_TIME' undeclared (first use in this function) 115 | FUSE2_ON_TIME = 0; | ^~~~~~~~~~~~~ ../icode/menu/menu.c: At top level: ../icode/menu/menu.c:141:6: error: conflicting types for 'editBuffer'; have 'char[12]' 141 | char editBuffer[12] = {0}; // ��ʼ�������� | ^~~~~~~~~~ ../icode/menu/menu.c:136:6: note: previous declaration of 'editBuffer' with type 'char[5]' 136 | char editBuffer[5]; // �༭������ | ^~~~~~~~~~ ../icode/menu/menu.c: In function 'edit_value': ../icode/menu/menu.c:151:13: error: 'editTitle' undeclared (first use in this function) 151 | strncpy(editTitle, title, sizeof(editTitle)-1); | ^~~~~~~~~ ../icode/menu/menu.c: In function 'display_data': ../icode/menu/menu.c:168:27: warning: passing argument 3 of 'OLED_ShowString' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 168 | OLED_ShowString(5, 5, title, OLED_8X16); | ^~~~~ In file included from ../icode/menu/menu.c:14: ../icode/menu/../../icode/oled/oled.h:38:50: note: expected 'char *' but argument is of type 'const char *' 38 | void OLED_ShowString(int16_t X, int16_t Y, char *String, uint8_t FontSize); | ~~~~~~^~~~~~ ../icode/menu/menu.c: In function 'handle_edit_menu': ../icode/menu/menu.c:259:31: error: 'editTitle' undeclared (first use in this function) 259 | OLED_ShowString(5, 0, editTitle, OLED_8X16); | ^~~~~~~~~ ../icode/menu/menu.c:270:68: error: 'WHITE' undeclared (first use in this function) 270 | OLED_DrawRectangle(cursor_x, 32, cursor_x + 6, 32 + 2, WHITE); | ^~~~~ ../icode/menu/menu.c:279:18: warning: implicit declaration of function 'Key_GetNum_NonBlocking' [-Wimplicit-function-declaration] 279 | KeyNum = Key_GetNum_NonBlocking(); | ^~~~~~~~~~~~~~~~~~~~~~ ../icode/menu/menu.c:309:17: warning: implicit declaration of function 'show_message' [-Wimplicit-function-declaration] 309 | show_message("Invalid value!"); | ^~~~~~~~~~~~ ../icode/menu/menu.c:318:13: error: unknown type name 'FlashStatus'; did you mean 'FlagStatus'? 318 | FlashStatus status = save_params_to_flash(); | ^~~~~~~~~~~ | FlagStatus ../icode/menu/menu.c:319:26: error: 'FLASH_OK' undeclared (first use in this function); did you mean 'FLASH'? 319 | if(status == FLASH_OK) { | ^~~~~~~~ | FLASH ../icode/menu/menu.c:322:17: warning: implicit declaration of function 'show_error_message' [-Wimplicit-function-declaration] 322 | show_error_message(status); | ^~~~~~~~~~~~~~~~~~ ../icode/menu/menu.c: At top level: ../icode/menu/menu.c:359:6: warning: conflicting types for 'show_message'; have 'void(const char *)' 359 | void show_message(const char *msg) { | ^~~~~~~~~~~~ ../icode/menu/menu.c:309:17: note: previous implicit declaration of 'show_message' with type 'void(const char *)' 309 | show_message("Invalid value!"); | ^~~~~~~~~~~~ ../icode/menu/menu.c: In function 'show_message': ../icode/menu/menu.c:361:28: warning: passing argument 3 of 'OLED_ShowString' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 361 | OLED_ShowString(5, 16, msg, OLED_8X16); | ^~~ ../icode/menu/../../icode/oled/oled.h:38:50: note: expected 'char *' but argument is of type 'const char *' 38 | void OLED_ShowString(int16_t X, int16_t Y, char *String, uint8_t FontSize); | ~~~~~~^~~~~~ ../icode/menu/menu.c: At top level: ../icode/menu/menu.c:368:25: error: unknown type name 'FlashStatus'; did you mean 'FlagStatus'? 368 | void show_error_message(FlashStatus status) { | ^~~~~~~~~~~ | FlagStatus ../icode/menu/menu.c:396:9: error: conflicting types for 'Key_GetNum_NonBlocking'; have 'uint8_t(void)' {aka 'unsigned char(void)'} 396 | uint8_t Key_GetNum_NonBlocking(void) { | ^~~~~~~~~~~~~~~~~~~~~~ ../icode/menu/menu.c:279:18: note: previous implicit declaration of 'Key_GetNum_NonBlocking' with type 'int()' 279 | KeyNum = Key_GetNum_NonBlocking(); | ^~~~~~~~~~~~~~~~~~~~~~ make: *** [icode/menu/subdir.mk:19: icode/menu/menu.o] Error 1 "make -j20 all" terminated with exit code 2. Build might be incomplete. 19:49:49 Build Failed. 21 errors, 6 warnings. (took 1s.258ms) 修改代码
07-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值