Welcome! Log In Create A New Profile

Advanced

How do I add a global variable accessible to multiple files in marlin?

Posted by jamesthegreat 
How do I add a global variable accessible to multiple files in marlin?
August 09, 2018 07:33PM
I am trying to add a simple boolean variable that I can change from multiple files. Atleast be able to change from marlin_main.cpp. I read I have to declare on a header file then define on one other file that includes the header and I should be able to use it.

I added
static bool endstopDisabled;
to the header file then declared it in its .cpp file
bool endstopDisabled;

It compiles fine but when I try to use it like this
endstopDisabled = false;
below in the same .cpp file it doesn't compile. It gives me the error "Error compiling for board Sanguino.". Anyone know what I am doing wrong? all I need is a boolean variable accessible to 2 files. Marlin_main.cpp and endstops.cpp. I am declaring variable in endstops.h.

Thank you in advance.
Re: How do I add a global variable accessible to multiple files in marlin?
August 09, 2018 09:32PM
I got it. this question was a bit dumb. how do I delete it?
Sorry, only registered users may post in this forum.

Click here to login