PlatformIO Community

Firebase Configuration Issue When Used in Header File

Hi, I was trying to use firebase in my latest project. When I add the Firebase_ESP_Client library to my project and use it in a .cpp file it works fine. However, when I try making the FirebaseData object a global variable by placing it in a header file, I run into multiple problems:

Here are the output errors:

.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/QueryFilter.h:74:35: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/QueryFilter.h:77:37: error: expected nested-name-specifier before 'enable_if'
     auto equalTo(T val) -> typename enable_if<is_num_int<T>::value, QueryFilter &>::type { return mEqualTo(toStringPtr(val), false); }
                                     ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/QueryFilter.h:77:37: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/QueryFilter.h:80:37: error: expected nested-name-specifier before 'enable_if'
     auto equalTo(T val) -> typename enable_if<is_string<T>::value, QueryFilter &>::type { return mEqualTo(toStringPtr(val), true); }
                                     ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/QueryFilter.h:80:37: error: expected initializer before 'enable_if'
In file included from .pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/Firebase.h:65,
                 from .pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/Firebase_ESP_Client.h:42,
                 from src/firebase.h:4,
                 from src/main.cpp:25:
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:615:25: error: expected nested-name-specifier before 'enable_if'
   auto to() -> typename enable_if<is_num_int<T>::value || is_num_float<T>::value || is_bool<T>::value, T>::type
                         ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:615:25: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:668:25: error: expected nested-name-specifier before 'enable_if'
   auto to() -> typename enable_if<is_const_chars<T>::value || is_std_string<T>::value || is_arduino_string<T>::value || is_mb_string<T>::value, T>::type
                         ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:668:25: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:676:25: error: expected nested-name-specifier before 'enable_if'
   auto to() -> typename enable_if<is_same<T, FirebaseJson *>::value, FirebaseJson *>::type
                         ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:676:25: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:692:25: error: expected nested-name-specifier before 'enable_if'
   auto to() -> typename enable_if<is_same<T, FirebaseJsonData *>::value, FirebaseJsonData *>::type
                         ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:692:25: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:700:25: error: expected nested-name-specifier before 'enable_if'
   auto to() -> typename enable_if<is_same<T, FirebaseJson>::value, FirebaseJson &>::type
                         ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:700:25: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:706:25: error: expected nested-name-specifier before 'enable_if'
   auto to() -> typename enable_if<is_same<T, FirebaseJsonArray *>::value, FirebaseJsonArray *>::type
                         ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:706:25: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:723:25: error: expected nested-name-specifier before 'enable_if'
   auto to() -> typename enable_if<is_same<T, FirebaseJsonArray>::value, FirebaseJsonArray &>::type
                         ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:723:25: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:729:25: error: expected nested-name-specifier before 'enable_if'
   auto to() -> typename enable_if<is_same<T, MB_VECTOR<uint8_t> *>::value, MB_VECTOR<uint8_t> *>::type
                         ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:729:25: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:736:25: error: expected nested-name-specifier before 'enable_if'
   auto to() -> typename enable_if<is_same<T, fs::File>::value, fs::File>::type
                         ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/session/FB_Session.h:736:25: error: expected initializer before 'enable_if'
In file included from .pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/Firebase.h:74,
                 from .pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/Firebase_ESP_Client.h:42,
                 from src/firebase.h:4,
                 from src/main.cpp:25:
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1888:106: error: expected nested-name-specifier before 'enable_if'
   auto dataPushHandler(FirebaseData *fbdo, T1 path, T2 value, int priority_addr, bool async) -> typename enable_if<is_string<T1>::value && is_num_int<T2>::value, bool>::type
                                                                                                          ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1888:106: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1894:106: error: expected nested-name-specifier before 'enable_if'
   auto dataPushHandler(FirebaseData *fbdo, T1 path, T2 value, int priority_addr, bool async) -> typename enable_if<is_string<T1>::value && is_bool<T2>::value, bool>::type
                                                                                                          ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1894:106: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1900:106: error: expected nested-name-specifier before 'enable_if'
   auto dataPushHandler(FirebaseData *fbdo, T1 path, T2 value, int priority_addr, bool async) -> typename enable_if<is_string<T1>::value && is_same<T2, float>::value, bool>::type
                                                                                                          ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1900:106: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1906:106: error: expected nested-name-specifier before 'enable_if'
   auto dataPushHandler(FirebaseData *fbdo, T1 path, T2 value, int priority_addr, bool async) -> typename enable_if<is_string<T1>::value && is_same<T2, double>::value, bool>::type
                                                                                                          ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1906:106: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1912:106: error: expected nested-name-specifier before 'enable_if'
   auto dataPushHandler(FirebaseData *fbdo, T1 path, T2 value, int priority_addr, bool async) -> typename enable_if<is_string<T1>::value && is_string<T2>::value, bool>::type
                                                                                                          ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1912:106: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1918:105: error: expected nested-name-specifier before 'enable_if'
   auto dataPushHandler(FirebaseData *fbdo, T1 path, T2 json, int priority_addr, bool async) -> typename enable_if<is_string<T1>::value && is_same<T2, FirebaseJson *>::value, bool>::type
                                                                                                         ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1918:105: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1924:104: error: expected nested-name-specifier before 'enable_if'
   auto dataPushHandler(FirebaseData *fbdo, T1 path, T2 arr, int priority_addr, bool async) -> typename enable_if<is_string<T1>::value && is_same<T2, FirebaseJsonArray *>::value, bool>::type
                                                                                                        ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1924:104: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1930:99: error: expected nested-name-specifier before 'enable_if'
   auto dataPushHandler(FirebaseData *fbdo, T1 path, T2 blob, size_t size, bool async) -> typename enable_if<is_string<T1>::value && is_same<T2, uint8_t *>::value, bool>::type
                                                                                                   ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1930:99: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1936:127: error: expected nested-name-specifier before 'enable_if'
   auto dataPushHandler(FirebaseData *fbdo, T1 path, T2 filename, fb_esp_mem_storage_type storageType, bool async) -> typename enable_if<is_string<T1>::value && is_string<T2>::value, bool>::type
                                                                                                                               ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1936:127: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1942:114: error: expected nested-name-specifier before 'enable_if'
   auto dataSetHandler(FirebaseData *fbdo, T1 path, T2 value, int priority_addr, T3 etag, bool async) -> typename enable_if<is_string<T1>::value && is_bool<T2>::value, bool>::type
                                                                                                                  ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1942:114: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1948:114: error: expected nested-name-specifier before 'enable_if'
   auto dataSetHandler(FirebaseData *fbdo, T1 path, T2 value, int priority_addr, T3 etag, bool async) -> typename enable_if<is_string<T1>::value && is_num_int<T2>::value, bool>::type
                                                                                                                  ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1948:114: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1954:114: error: expected nested-name-specifier before 'enable_if'
   auto dataSetHandler(FirebaseData *fbdo, T1 path, T2 value, int priority_addr, T3 etag, bool async) -> typename enable_if<is_string<T1>::value && is_same<T2, float>::value, bool>::type
                                                                                                                  ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1954:114: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1960:114: error: expected nested-name-specifier before 'enable_if'
   auto dataSetHandler(FirebaseData *fbdo, T1 path, T2 value, int priority_addr, T3 etag, bool async) -> typename enable_if<is_string<T1>::value && is_same<T2, double>::value, bool>::type
                                                                                                                  ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1960:114: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1966:114: error: expected nested-name-specifier before 'enable_if'
   auto dataSetHandler(FirebaseData *fbdo, T1 path, T2 value, int priority_addr, T3 etag, bool async) -> typename enable_if<is_string<T1>::value && is_string<T2>::value, bool>::type
                                                                                                                  ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1966:114: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1972:113: error: expected nested-name-specifier before 'enable_if'
   auto dataSetHandler(FirebaseData *fbdo, T1 path, T2 json, int priority_addr, T3 etag, bool async) -> typename enable_if<is_string<T1>::value && is_same<T2, FirebaseJson *>::value, bool>::type
                                                                                                                 ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1972:113: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1978:112: error: expected nested-name-specifier before 'enable_if'
   auto dataSetHandler(FirebaseData *fbdo, T1 path, T2 arr, int priority_addr, T3 etag, bool async) -> typename enable_if<is_string<T1>::value && is_same<T2, FirebaseJsonArray *>::value, bool>::type
                                                                                                                ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1978:112: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1984:113: error: expected nested-name-specifier before 'enable_if'
   auto dataSetHandler(FirebaseData *fbdo, T1 path, uint8_t *blob, size_t size, T2 etag, bool async) -> typename enable_if<is_string<T1>::value, bool>::type
                                                                                                                 ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1984:113: error: expected initializer before 'enable_if'
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1990:135: error: expected nested-name-specifier before 'enable_if'
   auto dataSetHandler(FirebaseData *fbdo, T1 path, T2 filename, fb_esp_mem_storage_type storageType, T3 etag, bool async) -> typename enable_if<is_string<T1>::value && is_string<T2>::value, bool>::type
                                                                                                                                       ^~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/rtdb/FB_RTDB.h:1990:135: error: expected initializer before 'enable_if'
In file included from .pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/./mbfs/MB_FS_Interfaces.h:90,
                 from .pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/./mbfs/MB_FS.h:37,
                 from .pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/FB_Const.h:45,
                 from .pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/FB_Utils.h:37,
                 from .pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/Firebase.h:62,
                 from .pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/Firebase_ESP_Client.h:42,
                 from src/firebase.h:4,
                 from src/main.cpp:25:
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/json/FirebaseJson.h: In instantiation of 'bool FirebaseJson::setJsonData(T) [with T = const char*]':
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/FB_Utils.h:657:35:   required from here
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/json/FirebaseJson.h:2357:33: error: 'getStr' was not declared in this scope
         bool ret = setRaw(getStr(data, addr));
                           ~~~~~~^~~~~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/json/FirebaseJson.h:2357:33: note: suggested alternative: 'get'
         bool ret = setRaw(getStr(data, addr));
                           ~~~~~~^~~~~~~~~~~~
                           get
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/json/FirebaseJson.h: In instantiation of 'bool FirebaseJson::get(FirebaseJsonData&, T, bool) [with T = const char*]':
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/FB_Utils.h:658:54:   required from here
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/json/FirebaseJson.h:2502:46: error: 'getStr' was not declared in this scope
         bool ret = mGet(root, &result, getStr(path, addr), prettify);
                                        ~~~~~~^~~~~~~~~~~~
.pio/libdeps/esp32dev/Firebase Arduino Client Library for ESP8266 and ESP32/src/json/FirebaseJson.h:2502:46: note: suggested alternative: 'get'
         bool ret = mGet(root, &result, getStr(path, addr), prettify);
                                        ~~~~~~^~~~~~~~~~~~
                                        get
*** [.pio\build\esp32dev\src\main.o] Error 1

Here’s my header file (firebase.h):

#ifndef firebase_H_

#define firebase_H_
#include <Arduino.h>
#include <string.h>

#include <Firebase_ESP_Client.h>

void firebaseSetup();

void firebaseLoopSend();

void firebaseLoopRead();

void firebaseWriteData(String topic, void* value, char* datatype);

//Define Firebase Data object

extern FirebaseData fbdo;

extern FirebaseAuth auth;

extern FirebaseConfig config;

#endif

Here is my firebase.cpp file:

#include <Arduino.h>
#if defined(ESP32)
  #include <WiFi.h>
#elif defined(ESP8266)
  #include <ESP8266WiFi.h>
#endif
#include <Firebase_ESP_Client.h>
#include "firebase.h"

//Provide the token generation process info.
#include "addons/TokenHelper.h"
//Provide the RTDB payload printing info and other helper functions.
#include "addons/RTDBHelper.h"

// Insert your network credentials
#define WIFI_SSID "SSID_HERE"
#define WIFI_PASSWORD "PW_HERE"

// Insert Firebase project API Key
#define API_KEY "API_KEY_HERE"

// Insert RTDB URLefine the RTDB URL */
#define DATABASE_URL "URL_HERE" 

//Define Firebase Data object
FirebaseData fbdo;

FirebaseAuth auth;
FirebaseConfig config;

unsigned long sendDataPrevMillis = 0;
int count = 0;
bool signupOK = false;

int intValue;
float floatValue;

void firebaseSetup(){
  //Serial.begin(115200);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("Connecting to Wi-Fi");
  while (WiFi.status() != WL_CONNECTED){
    Serial.print(".");
    delay(300);
  }
  Serial.println();
  Serial.print("Connected with IP: ");
  Serial.println(WiFi.localIP());
  Serial.println();

  /* Assign the api key (required) */
  config.api_key = API_KEY;

  /* Assign the RTDB URL (required) */
  config.database_url = DATABASE_URL;

  /* Sign up */
  if (Firebase.signUp(&config, &auth, "", "")){
    Serial.println("ok");
    signupOK = true;
  }
  else{
    Serial.printf("%s\n", config.signer.signupError.message.c_str());
  }

  /* Assign the callback function for the long running token generation task */
  config.token_status_callback = tokenStatusCallback; //see addons/TokenHelper.h
  
  Firebase.begin(&config, &auth);
  Firebase.reconnectWiFi(true);
  //firebaseLoopSend();
  disableCore0WDT();
  disableCore1WDT();
  firebaseWriteData("Test2/String", (void*)"Matthew got this working", "String");
  firebaseLoopRead();
}

void firebaseLoopSend(){
  while (true){
    if (Firebase.ready() && signupOK && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)){
    sendDataPrevMillis = millis();
        // Write an Int number on the database path test/int
        if (Firebase.RTDB.setInt(&fbdo, "test/int", count)){
        Serial.println("PASSED");
        Serial.println("PATH: " + fbdo.dataPath());
        Serial.println("TYPE: " + fbdo.dataType());
        }
        else {
        Serial.println("FAILED");
        Serial.println("REASON: " + fbdo.errorReason());
        }
        count++;
        
        // Write an Float number on the database path test/float
        if (Firebase.RTDB.setFloat(&fbdo, "test/float", 0.01 + random(0,100))){
        Serial.println("PASSED");
        Serial.println("PATH: " + fbdo.dataPath());
        Serial.println("TYPE: " + fbdo.dataType());
        }
        else {
        Serial.println("FAILED");
        Serial.println("REASON: " + fbdo.errorReason());
        }
    }
  }
}

void firebaseLoopRead()
{
  while(true){
        if (Firebase.ready() && signupOK && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) {
      sendDataPrevMillis = millis();
      if (Firebase.RTDB.getInt(&fbdo, "/test/int")) {
        if (fbdo.dataType() == "int") {
          intValue = fbdo.intData();
          Serial.println(intValue);
        }
      }
      else {
        Serial.println(fbdo.errorReason());
      }
      
      if (Firebase.RTDB.getFloat(&fbdo, "/test/float")) {
        if (fbdo.dataType() == "float") {
          floatValue = fbdo.floatData();
          Serial.println(floatValue);
        }
      }
      else {
        Serial.println(fbdo.errorReason());
      }
    }
  }
}

void firebaseWriteData(String topic, void* value, char* datatype)
{
    if (Firebase.ready() && signupOK)
    {
        if (strcmp(datatype, "String") == 0)
        {
            Firebase.RTDB.setString(&fbdo, topic, (char*)value);
        }
    }

}

Just to reiterate, if I remove the line #include <Firebase_ESP_Client.h> from my header file, I don’t get these errors. However, I need this line to make the FirebaseData fbdo object global (so that I can read and write data to the database from other files). How can I get around this issue?

Is it the same when just #include "firebase.h" in main.cpp?

No, it doesn’t give me errors when I place this line in a .cpp file. Only when I place this #include statement in a header file do I get errors but I want to make the firebase object global so I can use it in other files. How can I do that?

Please file an issue at Issues · mobizt/Firebase-ESP-Client · GitHub, they know their code best.

I am having the same issue making a header file for firebase.
Did u solve it?
if you do, please share your soluction!!

No, but I figured out a workaround. Instead of making the firebase data object a global, I just made included the following function in the same .cpp file as my fbdo object:

void firebaseWriteData(String topic, void* value, char* datatype)
{
    if (Firebase.ready() && signupOK)
    {
        if (strcmp(datatype, "String") == 0)
        {
            Firebase.RTDB.setString(&fbdo, topic, (char*)value);
        }
        else if(strcmp(datatype, "int") == 0)
        {
          Firebase.RTDB.setInt(&fbdo, topic, (int)value);
        }
        else if(strcmp(datatype, "float") == 0)
        {
          Firebase.RTDB.setFloat(&fbdo, topic, *(float *)&value);
        }
    }
}

I then declared this function in my header file database.h as such:

void firebaseWriteData(String topic, void* value, char* datatype);

Now if I want to use it, I can make a call from any file in my codebase like such:

#include "database.h"

  firebaseWriteData("Test2/String", (void*)"Matthew got this working", "String");