相互矛盾的性格声明
Conflicting declaration of character
我目前正在做一个 Arduino 项目,我需要 WiFi.h 和 MySQL_Connection.h 库。
变量"password"在这两个库中都使用了,因此会导致冲突。
我该如何解决这个问题?我对这个平台还是很陌生,因此任何可能的解决方案都必须易于理解。提前致谢。
Arduino 提供的错误信息:"exit status 1 conflicting declaration 'char password []'"
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
我会选择 header,它为您的代码提供的内容较少,并将其放在命名空间中:
#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
如果这不起作用,请在评论中告诉我结果,我们会进行更多修改。如果可行,请注意,您仍然需要努力学习命名空间。
我目前正在做一个 Arduino 项目,我需要 WiFi.h 和 MySQL_Connection.h 库。
变量"password"在这两个库中都使用了,因此会导致冲突。
我该如何解决这个问题?我对这个平台还是很陌生,因此任何可能的解决方案都必须易于理解。提前致谢。
Arduino 提供的错误信息:"exit status 1 conflicting declaration 'char password []'"
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
我会选择 header,它为您的代码提供的内容较少,并将其放在命名空间中:
#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
如果这不起作用,请在评论中告诉我结果,我们会进行更多修改。如果可行,请注意,您仍然需要努力学习命名空间。