lua - 尝试在 ldebug.c 中包含 httpclient.h 会导致编译期间出错
问题描述
我的目标是通过包含 httpclient 在 ldebug.c 中执行 http post 请求。它在 dbg_printf.c 中有效,但在 ldebug.c 中出现编译错误。
In file included from ../ldebug.c:28:0:
../../http/httpclient.h:69:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'http_request'
void ICACHE_FLASH_ATTR http_request(const char * url, const char * method, const char * headers, const char * post_data, http_callback_t callback_handle, int redirect_follow_count);
还有另一种方法可以进行发布请求吗?
解决方案
ICACHE_FLASH_ATTR
是文件c_types.h中定义的宏
没有定义的原因有两个。
首先,ldebug.c 可能不包含 c_types.h 或包含 #includes c_types.h 的文件。这很容易修复 - 编辑 ldebug.c 并添加
#include <c_types.h>
前#include <httpclient.h>
另一种可能性是ICACHE_FLASH
编译 ldebug.c 时未定义符号。文件 c_types.h 仅定义ICACHE_FLASH_ATTR
是否ICACHE_FLASH
为 #define'd。如果第一个修复不起作用,则需要确保#define ICACHE_FLASH
在编译 ldebug.c 时
最简单的方法是添加
#define ICACHE_FLASH 1
作为 ldebug.c 的第一行
或者,您可以确保-DICACHE_FLASH=1
在任何开发环境中都设置为编译器标志。更改 ldebug.c 几乎可以肯定是更简单的方法。
推荐阅读
- windows - React Native (Android) Windows 10 调试 - 源映射未正确加载
- python - 收到 ImportError: cannot import name x from y
- javascript - 如何在函数内部声明一个 JavaScript 全局变量?
- security - 如何合并 2 个证书文件以创建链文件证书
- python - 我可以让python在不提供路径的情况下读取pdf,而是通过在计算机上打开文件来代替吗?
- react-native - 如何仅显示来自 expo-barcode-scanner 的视频馈送的方形部分?
- python - 将一系列计数拆分为 bin,以便这些 bin 包含相似的计数和
- javascript - 使用 POSTMAN 发布数据后未获取数据
- r - 使用官员导出到 .pptx 时,绘图被压扁
- php - laravel nova - 如何制作有限制的自引用模型