Header files report errors

main.cpp file with header files to manage code works perfectly and overall builds a working project.

Whats bothering me is that when I edit and mess around with the header files they cant see variables I use in them from the main.cpp file therefore creating errors that wont affect the main.cpp build but whilst editing header.h it will overflow the normal errors that time over time get in there and are very hard to find.

Is there a way to back point at the main.cpp file from the header.h to let it know the variables?

Could you provide test project to debug this issue?

I have already solved the problem by using extern to let the header file know about the values, It didnt work the first time because I used the command in a wrong way that didnt work, but now it’s alright.