Częśc. Czy mógłby ktoś sprawdzić ten kawałek kodu? Niestety nie mogę znależć rozwiązania a porównując z tymi co znalazłem w necie wydaje się że powinno być dobrze
Błąd to:
undefined reference to `JsonFonts::instance' JsonFonts.h line 32
/*
* JsonFonts.h
*
* Created on: 16 lut 2021
* Author: danie
*/
#include <vector>
#include <cardSD.h>
#include <ArduinoJson-v6.15.2.h>
#ifndef SRC_FILEMANAGER_JSONFONTS_H_
#define SRC_FILEMANAGER_JSONFONTS_H_
class JsonFonts {
private:
JsonFonts();
virtual ~JsonFonts();
static JsonFonts* instance;
struct FontsSettings{
std::string font;
uint8_t height;
uint8_t width;
string path;
};
FontsSettings actualSettings;
vector<FontsSettings> fontsSettings;
public:
static JsonFonts* getInstance(){
if(instance == nullptr)
instance = new JsonFonts();
return instance;
}
void findFontToCreate(uint8_t width, uint8_t height);
string getPath(uint8_t width, uint8_t height);
uint8_t getWidth(uint8_t width, uint8_t height);
uint8_t getHeight(uint8_t width, uint8_t height);
};
#endif /* SRC_FILEMANAGER_JSONFONTS_H_ */
jf
jest inicjalizowany (wywołany zostanie konstruktor) dopiero wtedy, kiedy sterowanie po raz pierwszy zostanie przekazane do funkcjiinstance
. Następne jej wywołania nie będą już inicjalizowały/tworzyły tego obiektu.