Quantcast
Channel: Reprap Forum - Firmware - Marlin
Viewing all articles
Browse latest Browse all 2831

How do I add a global variable accessible to multiple files in marlin? (1 reply)

$
0
0
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.

Viewing all articles
Browse latest Browse all 2831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>