Can't compile my library because "String does not name a type" I am writing a small library to move some code out of the arduino sketch and make it reusable. Problem is that it does not compile since &quot;String does not name a type&quot;.
This is my code (reduced):
myESP.h:
#ifndef MYESP_H
#define MYESP_H

#include &quot;Arduino.h&quot;

#include &lt;String&gt;

#include &lt;ESP8266WiFi.h&gt;
#include &lt;ESP8266WiFiMulti.h&gt;
#include &lt;WiFiClient.h&gt;
#include &lt;WiFiClientSecure.h&gt;
#include &lt;WiFiServer.h&gt;
#include &lt;WiFiUdp.h&gt;
 
class myESP {
    private:
        const char* _ssid;
        const char* _password;
        const char* _host;
    public:
        myESP();
        myESP(char * ssid, char * pwd, char * host);
        String macToStr(const uint8_t* mac);
        String doGet(String data, String sensor, int duration);
};
#endif

myESP.cpp:
#include &lt;String&gt;

#include &quot;Arduino.h&quot;
#include &quot;myESP.h&quot;

myESP::myESP() {}

myESP::myESP(char * ssid, char * pwd, char * host) {
    _host = host;
    _password = pwd;
    _ssid = ssid;
}

myESP::String macToStr(const uint8_t* mac) {
}

myESP::String doGet(String data, String sensor, int duration) {

}

When i try to compile it, I get the following:

/Users/lbedogni/Documents/Arduino/libraries/myESP/myESP.cpp:14:1:
error: 'String' in 'class myESP' does not name a type  myESP::String
macToStr(const uint8_t* mac) {
/Users/lbedogni/Documents/Arduino/libraries/myESP/myESP.cpp:22:1:
error: 'String' in 'class myESP' does not name a type  myESP::String
doGet(String data, String sensor, int duration) {

I have tried to change the order of the imports, change libraries, but still it does not compile.
Any idea?
Your syntax is wrong in myESP.cpp. Change this:

myESP::String macToStr(const uint8_t* mac) {
}

myESP::String doGet(String data, String sensor, int duration) {

}


to this:

String myESP::macToStr(const uint8_t* mac) {
}

String myESP::doGet(String data, String sensor, int duration) {

}


The return type is String and the function implementation should be prefixed with the class name myESP::. Obviously, you also need to fill in the body of the implementation or you'll get more errors because you don't actually return anything.