我目前正在从事一个Arduino项目,在那里我需要WiFi.h和MySQL_Connection.h库。
变量"password“在这两个库中都使用,因此会引起冲突。
我怎样才能解决这个问题?我对这个平台还是很陌生的,因此任何可能的解决方案都必须很容易理解。提前谢谢。
Arduino提供的错误消息:“退出状态1冲突声明'char密码[]'”
include <Ethernet.h>
#include "WiFi.h";
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//Wifi
//Wifi connection, this call is to the Wifi.h library
const char* ssid = "pp******";
const char* password = "*******";
//This call is to the <MySQL_Connection.h> library
IPAddress server_addr(10,0,1,35); // IP of the MySQL *server* here
char user[] = "root"; // MySQL user login username
char password[] = "secret"; // MySQL user login password发布于 2020-04-28 16:01:40
我会选择为代码提供更少内容的标题,并将其放在名称空间中:
#include "WiFi.h"
namespace mySQL
{
#include "MySQL_Connection.h"
}
using mySQL::something;
using mySQL::something_else;
...
foo(password);
bar(mySQL::password);编辑:我不清楚您发布的代码是如何工作的,但请尝试如下:
include <Ethernet.h>
namespace Wifi
{
#include "WiFi.h";
const char* password = "*******";
}
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
const char* ssid = "pp******";
IPAddress server_addr(10,0,1,35); // IP of the MySQL *server* here
char user[] = "root"; // MySQL user login username
char password[] = "secret"; // MySQL user login password如果这不起作用,告诉我在评论中的结果,我们会修改更多。如果它有效,请注意,您仍然需要努力学习名称空间。
https://stackoverflow.com/questions/61484315
复制相似问题