我正在将一个现有库("Webduino",用于Arduino的Web服务器)适配到另一个现有库("WiFly",一种wifi模块),但遇到了问题。每个库单独运行都很好。Webduino库希望通过SPI使用以太网硬件模块,而WiFi模块则使用串口(UART)。我收到的错误信息是:
WiFlyClient.h: In member function 'WiFlyClient& WiFlyClient::operator=(const WiFlyClient&)':
WiFlyClient.h:14:
error: non-static reference member 'WiFlyDevice& WiFlyClient::_WiFly', can't use default assignment operator
WiFlyWebServer.h: In member function 'void WebServer::processConnection(char*, int*)':
WiFlyWebServer.h:492: note: synthesized method 'WiFlyClient& WiFlyClient::operator=(const WiFlyClient&)' first required here
以下是相关的代码片段。请注意,到目前为止,我只修改了WiFlyWebServer.h(Webduino)文件:
// WiFlyWebServer.h (Webduino)
...
WiFlyServer m_server; // formerly EthernetServer and
WiFlyClient m_client; // EthernetClient
...
void WebServer::processConnection(char *buff, int *bufflen){
...
// line 492
m_client = m_server.available();
...
}
// WiFlyClient.h
class WiFlyClient : public Client {
public:
WiFlyClient();
...
private:
WiFlyDevice& _WiFly;
...
}
// WiFlyClient.cpp
#include "WiFly.h"
#include "WiFlyClient.h"
WiFlyClient::WiFlyClient() :
_WiFly (WiFly) { // sets _wiFly to WiFly, which is an extern for WiFlyDevice (WiFly.h)
...
}
// WiFly.h
#include "WiFlyDevice.h"
...
extern WiFlyDevice WiFly;
...
// WiFlyDevice.h
class WiFlyDevice {
public:
WiFlyDevice(SpiUartDevice& theUart);
...
// WiFlyDevice.cpp
WiFlyDevice::WiFlyDevice(SpiUartDevice& theUart) : SPIuart (theUart) {
/*
Note: Supplied UART should/need not have been initialised first.
*/
...
}
问题源自于
m_client = m_server.available();
这一行,如果我注释掉它,问题就会消失(但整个程序都依赖于这行代码)。实际问题似乎是在WiFiClient对象被赋值时无法初始化(覆盖?)_WiFly成员,但我不明白为什么在没有修改的情况下可以工作而在这里却不行。(是的,我知道头文件中有实现,我不知道为什么他们要这样写,别怪我!)
有什么见解吗?
_WiFly
是为实现保留的。 - chris_WiFly
在构造函数中已经正确初始化了,所以可以忽略它。 - Lol4t0保留在任何范围内,包括用作实现宏的标识符:以下划线和大写字母开头的标识符
。全局范围的则是以下划线开头。 - chris