BriComp
Well-known member
I am a relative newby to c++ and I could do with some help.
I am trying to pass a type from a header file to an ino but it's not compiling.
I have generated a cut down example to demonstrate the problem.
I have searched the web for help but nothing has.
Here is the cut down code:-
TestHeader.h
TestHeader.cpp
Test.ino
I am trying to pass a type from a header file to an ino but it's not compiling.
I have generated a cut down example to demonstrate the problem.
I have searched the web for help but nothing has.
Here is the cut down code:-
TestHeader.h
Code:
#pragma once
#include "Arduino.h"
class TestHeader {
public:
enum dirType {
forward,
backward
};
struct testType {
uint32_t aa;
uint32_t bb;
uint32_t cc;
uint32_t dd;
dirType ee;
uint32_t ff;
uint32_t gg;
bool hh;
};
testType SaveData();
private:
uint32_t a;
uint32_t b;
uint32_t c;
uint32_t d;
dirType e;
uint32_t f;
uint32_t g;
bool h;
};
Code:
#include "Arduino.h"
#include <TestHeader.h>
TestHeader::testType TestHeader::SaveData() {
testType tst;
tst.aa = a;
tst.bb = b;
tst.cc = c;
tst.dd = d;
tst.ee = e;
tst.ff = f;
tst.gg = g;
tst.hh = h;
return tst;
}
#include <Arduino.h>
#include <TestHeader.h>
TestType testData;
void setup()
{
testData = SaveData{};
}
// Add the main program code into the continuous loop() function
void loop()
{
}