0

这是代码和错误消息,在我使用代码之前,代码只是一个测试文件,当我只导入 Keypad.h 和 Keypad_I2C.h 时,它工作正常,当我只导入 ESP8266WiFi.h 时也工作. 当我尝试只导入 Keypad lib 和 ESP8266WiFi.h 之一并发生错误时。

代码:

#include <Keypad_I2C.h>
#include <Keypad.h>
//#include <ArduinoJson.h>
//#include<SoftwareSerial.h>
#include<ESP8266WiFi.h>
void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

错误信息:

In file included from sketch\ImportTest.ino.cpp:1:0:

C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266/Arduino.h:43:14: error: expected identifier before numeric constant

 #define HIGH 0x1

              ^

C:\Users\user\Documents\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'

 #define CLOSED HIGH

                ^

C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi\src/include/wl_definitions.h:73:3: note: in expansion of macro 'CLOSED'

   CLOSED      = 0,

   ^

C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266/Arduino.h:43:14: error: expected '}' before numeric constant

 #define HIGH 0x1

              ^

C:\Users\user\Documents\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'

 #define CLOSED HIGH

                ^

C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi\src/include/wl_definitions.h:73:3: note: in expansion of macro 'CLOSED'

   CLOSED      = 0,

   ^

C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266/Arduino.h:43:14: error: expected unqualified-id before numeric constant

 #define HIGH 0x1

              ^

C:\Users\user\Documents\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'

 #define CLOSED HIGH

                ^

C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi\src/include/wl_definitions.h:73:3: note: in expansion of macro 'CLOSED'

   CLOSED      = 0,

   ^

In file included from C:\Users\user\Documents\Arduino\ImportTest\ImportTest.ino:5:0:

C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi\src/ESP8266WiFi.h:29:1: error: expected declaration before '}' token

 }

 ^

Multiple libraries were found for "Keypad_I2C.h"
 Used: C:\Users\user\Documents\Arduino\libraries\arduino_keypads-master
Multiple libraries were found for "Keypad.h"
 Used: C:\Users\user\Documents\Arduino\libraries\Keypad
Multiple libraries were found for "Wire.h"
 Used: C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\WireESP8266
Multiple libraries were found for "ESP8266WiFi.h"
 Used: C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
Arduino: 1.8.10 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

In file included from sketch\ImportTest.ino.cpp:1:0:

C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266/Arduino.h:43:14: error: expected identifier before numeric constant

 #define HIGH 0x1

              ^

C:\Users\user\Documents\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'

 #define CLOSED HIGH

                ^

C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi\src/include/wl_definitions.h:73:3: note: in expansion of macro 'CLOSED'

   CLOSED      = 0,

   ^

C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266/Arduino.h:43:14: error: expected '}' before numeric constant

 #define HIGH 0x1

              ^

C:\Users\user\Documents\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'

 #define CLOSED HIGH

                ^

C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi\src/include/wl_definitions.h:73:3: note: in expansion of macro 'CLOSED'

   CLOSED      = 0,

   ^

C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266/Arduino.h:43:14: error: expected unqualified-id before numeric constant

 #define HIGH 0x1

              ^

C:\Users\user\Documents\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'

 #define CLOSED HIGH

                ^

C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi\src/include/wl_definitions.h:73:3: note: in expansion of macro 'CLOSED'

   CLOSED      = 0,

   ^

In file included from C:\Users\user\Documents\Arduino\ImportTest\ImportTest.ino:5:0:

C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi\src/ESP8266WiFi.h:29:1: error: expected declaration before '}' token

 }

 ^

Multiple libraries were found for "Keypad.h"
 Used: C:\Users\user\Documents\Arduino\libraries\Keypad
Multiple libraries were found for "ESP8266WiFi.h"
 Used: C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
4

1 回答 1

0

这是自 2017 年以来的一个已知功能。将键盘库作为标准库的最后一个:

//#include <ArduinoJson.h>
//#include<SoftwareSerial.h>
#include<ESP8266WiFi.h>

#include <Keypad_I2C.h>
#include <Keypad.h>

这编译得很好。
并为您省去更多麻烦。将 ArduinoIDE 更新到 1.8.12 -您的版本具有一些功能,例如串行监视器中缺少波特率选择,也不是真正有效的工具链。

于 2020-04-01T00:49:08.353 回答