Hello Everyone.
This might be a simple resolve, but I’ve been looking for the last hour on how to fix it and came up with nothing so far.
I have an Arduino Uno project structure like so:
My main source file is trying to import the headers from both “Thermistors.h” and “Probes.h.” Before mentioning anything else, note that this problem is still reproduced when leaving the files in the primary src
directory (where main is).
Probes.h is a class handler to hold numerous types of sensor types. Because of this, it needs access to the header file from the thermistor header file.
I have included pre-processor guards to avoid double importing namespace issues. However, I keep getting compiler errors where the compiler cannot identify the instantiated object type (it’s class).
Specifically from Intelisense:
This decleration does not have a storage class or type specifier
From what I’ve read from StackOverflow and other communities, this issue is more commonly seen when #include guards are not implemented or whenever a class is declared, but called elsewhere in the program before it has been fully defined.
Could this possibly be an issue with Platormio’s cMake configuration or is my code at fault? I’ve looked it over many times and I think my code should not be an issue here. I followed the examples instructions in the lib/README file which is why they are separated into their own directories within the Lib parent folder.
main.cpp
#include <pins_arduino.h>
#include <HardwareSerial.h>
#include <USBAPI.h>
#include <Thermistor.h>
#include <Probes.h>
Probes list;
Thermistor Thermistor1(PIN_A0, 20000, 3950, 5, 20000);
list.addThermistor(Thermistor1);
Thermistor.h
//
// Created by Aspen on 10/19/2020.
//
#ifndef THERMISTOR_H
#define THERMISTOR_H
class Thermistor
{
private:
Thermistor * head = nullptr;
int * logicalPinAddress = nullptr;
long * nominalResistance = nullptr;
int * beta = nullptr;
float * supplyVoltage = nullptr;
float * vo = nullptr;
float * r1 = nullptr;
float * r2 = nullptr;
float * temperatureCelsius = nullptr;
float * temperatureFahrenheit = nullptr;
public:
Thermistor();
Thermistor(int pinAddress, long int nominalResistance, int beta, float supplyVoltage, float R1) :
logicalPinAddress(&pinAddress), nominalResistance(&nominalResistance), beta(&beta), supplyVoltage(&supplyVoltage), r1(&R1) {};
void setLogicalPinAddress(int * pinAddress);
void setNominalResistance(long int * nominalResistance);
void setBeta(int * beta);
void setSupplyVoltage(float * supplyVoltage);
void setVo(float * vo);
void setR1(float * r1);
void setR2(float * r2);
void setTemperatureCelsius(float * temperatureCelsius);
void setTemperatureFahrenheit(float * temperatureFahrenheit);
int getLogicalPinAddress();
long int getNominalResistance();
int getBeta();
float getSupplyVoltage();
float getVo();
float getR1();
float getR2();
float getTemperatureCelsius();
float getTemperatureFahrenheit();
};
#endif //ARDUINO_TEMPERATURE_CONTROLLER_THERMISTOR
Probes.h
#ifndef PROBES_H
#define PROBES_H
#include <Thermistor.h>
class Probes
{
Thermistor * thermistors = nullptr;
int numThermistors ;
public:
Probes();
void addThermistor(Thermistor &thermistor);
void removeThermistor(Thermistor &thermistor);
String activeProbes();
};
#endif //ARDUINO_TEMPERATURE_CONTROLLER_PROBES
Note: Thermistor.cpp and Probes.cpp also must include their header files (I think this goes without saying)…