highlight.js

星期五, 9月 27, 2019

APDS9930 程式庫造成使用 bearssl 程式庫時編譯錯誤

如果你使用 ESP8266 為基礎的開發板, 例如 D1 mini, 搭配 APSD9930 程式庫, 同時又有使用到 ESP8266Wifi 程式庫的話, 依照以下順序撰寫 #incldue 敘述:

#include <APDS9930.h>
#include <ESP8266WiFi.h>
就會出現以下的編譯錯誤:
In file included from D:\FlagsBlockSketch.ino:3:0:
D:\arduino\libraries\APDS9930-master\src/APDS9930.h:134:33: error: expected ',' or '...' before numeric constant
#define B                       1.862
                                ^
D:\arduino\hardware\esp8266com\esp8266/tools/sdk/include/bearssl/bearssl_ec.h:412:60: note: in expansion of macro 'B'
uint32_t (*muladd)(unsigned char *A, const unsigned char *B, size_t len,
                                                          ^
這主要是因為 APDS9930.h 中定義了巨集 B 為 1.862, 而在 bearssl_ec.h 中個地方定義了函式的原型為:
uint32_t (*muladd)(unsigned char *A, const unsigned char *B, size_t len,
const unsigned char *x, size_t xlen,
const unsigned char *y, size_t ylen, int curve);
所以前置處理器會把 B 展開替換成 1.862, 所以這個函式原型就變成:

uint32_t (*muladd)(unsigned char *A, const unsigned char *1.862, size_t len,
const unsigned char *x, size_t xlen,
const unsigned char *y, size_t ylen, int curve);
而造成編譯錯誤, 錯誤訊息為:
error: expected ',' or '...' before numeric constant
這個問題我已經通知程式庫的原作者, 也發了 pull request 給他, 你可以自己把程式庫中的巨集 B 改名字, 或者是更改 #include 的順序, 把 APDS9930.h 放到最後就可以了。

1 則留言:

rabiapabich 提到...
網誌管理員已經移除這則留言。