为什么我收到未声明http_client_server的错误消息?

这是我的example.ino草图。

#include "http_server.h"

void setup() {
  Serial.begin(115200);
}

void loop() {
  HttpClientServer::http_client_server::startClient();
}

并且是http_client_server.cpp文件。

#include "http_client_server.h"
#include <ESP8266WebServer.h>

#define HTTP_REST_PORT 80
#define WIFI_RETRY_DELAY 500
#define MAX_WIFI_INIT_RETRY 50

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
ESP8266WebServer server(HTTP_REST_PORT);

namespace HttpClientServer
{
void http_client_server::startClient()
{
  server.handleClient();
}
}

这是我的头文件

// http_client_server.h
#ifndef HTTP_CLIENT_SERVER_H
#define HTTP_CLIENT_SERVER_H

namespace HttpClientServer
{
  class http_client_server 
  {
    public:
      static void startClient();
  };
}

#endif

但是当我尝试编译时,我总是出错,

http_client_server.cpp:13: error: 'http_client_server' has not been declared
 void http_client_server::startClient()
      ^
exit status 1
'http_client_server' has not been declared

但这是在头文件中明确定义的吗?

评论