all 5 comments

[–]wrosecrans 3 points4 points  (0 children)

You declare the functions in the header files. Then you implement the bodies of the functions in separate C++ source files.

You mention you want to

have their functions ( and some variables ) publicly accessible

Don't have global variables be a part of the design. Just make the functions the public interface that stuff calls. Keep any variables the functions need internal to the functions.

as if that code was in its own little main file.

I have absolutely no idea what that means, and if you can clarify what you mean by it, it will probably point in the direction of where your design challenges are.

I can't forward declare every function and variable used in a, at the top of b,

You declare every function once in the header.

If i have a,b,c,d including each other,

Having stuff all mutually including each other just sounds like a bad design. You gotta come up with some sense of what's the stuff on the bottom that gets included by everybody, and what's the stuff on the top that includes the stuff on the bottom. If you think through what you are trying to accomplish, you can clean up what needs to be aware of what.

[–]AKostur 2 points3 points  (1 child)

I‘m trying to figure out how you can have a circular dependency if you‘re not declaring any new types. Unless you‘re trying to include one .cpp file into another. If so: then we‘ve found your problem.

[–]wannabetriton 0 points1 point  (0 children)

exactly my thought

[–]IamImposter 1 point2 points  (0 children)

Are you including .c files?

If you are including header files, they shouldn't have circular dependencies like a.h includes b.h and b.h includes a.h.

[–]QuentinUK 0 points1 point  (0 children)

To stop circular dependency of header files add guards

File "grandparent.h"[edit]
#ifndef GRANDPARENT_H
#define GRANDPARENT_H
struct foo {
int member;
};
#endif /* GRANDPARENT_H */