Header of includes...not working

I have a header file with all of my custom class header files included in it and when I include that just the “includes” file in lower level classes it doesn’t work. I don’t know if this is a C++ by design, poor practice on my part (not all classes get all other classes included, just a few of the higher level classes) or an actual bug. In essence I am trying to create something like the application.h specific to my app but it doesn’t work. Below is an example of what I am doing.

#ifndef MainIncludes_H
#define MainIncludes_H

#define DEBUGME
#define	MyAppVersion	0.01;

#include "application.h"

#ifdef DEBUGME
	#define DEBUGp(message)		Serial.print(message)
	#define DEBUGpln(message)	Serial.println(message)
	#define DEBUGpub(event, message) Particle.publish(event, message, 21600, PRIVATE);
	#define DEBUGp(message)
	#define DEBUGpln(message)

#include "ClassA.h"
#include "ClassB.h"
#include "ClassC.h"
#include "ClassD.h"


This should work just the same as it does with application.h and even over several nesting levels (like Particle.h).

What exact error message do you get? And where are you including that “master” header (.h, .cpp or both)?

Another possible issue might be that you actually need some forward declarations in your headers if you have some inter-dependencies.

1 Like

I am including it in the header files of the lower level classes. The errors are related to enums and structs I have defined in said headers coming back with myClass_A_t does not name a type when I attempt to use them in ClassB or one of the higher level classes. If I add a direct include of ClassA.h to a class that is throwing the does not name a type message…it goes away.

Are thes typedefs or instances?
If you have an instance, you’d need to declare them extern in the files relying on them.

struct x { ... }; vs. struct { ... } x;

Typedefs. Then when I try to declare a new instance of that type in another class I get the does not name a type.

I’ve done this for a test

/// classa.h
#pragma once
#include "Particle.h"
typedef enum {
} e_type;


/// classb.h
#pragma once
#include "classa.h"
e_type e;
void fn(e_type tp) { Serial.println((int)tp); }

class x_class {
    e_type ex;
    x_class() { };
    void fnx(e_type tpx)  { Serial.println((int)tpx); };


/// dmy.ino
#include "classb.h"
e_type  ee;
x_class xx;
void setup() {
  pinMode(D7, OUTPUT);

void loop() {
  digitalWrite(D7, WiFi.ready());

and it works.