I've been programming/building Arduino projects on and off for many years but never got stuck like this...
I am modifying some code which is not my own but have studied it extensively. There are many modules so I will try to summarize the (simple) change I am making to the code and summarize where all the related/supporting code lives, highlighting the lines which produce error messages. All of this code is cut/paste so there or no UPPER/lower case errors.
I am adding a new boolean (bool) flag, "scubaMode", and then test an established input to set or clear (true or false) the variable. In another part of the code, I look at this flag to set another variable. No matter where or how I define the variable "scubaMode" (bool, extern bool, static bool, uint_7, int) I either get an undefined in scope error or an undefined reference error. Certainly this can't be that hard, but I have spent four hours on it now and gotten nowhere with it. Any help is very much appreciated.
Here are the relevant snippets, each with a "where it is in the code" label. I have placed the verify/compile errors on the relevant lines of code in the comment field.
in alternator.h
extern bool tachMode;
extern bool scubaMode;
in system.cpp
#if defined (OSE_ALTERNATOR) ||
defined (OSE_GENERATOR)
#include "Alternator.h"
** in config.h**
#define OSE_ALTERNATOR
Later in system.cpp
#ifdef FEATURE_IN_SCUBA
if (feature_in(false)==true)
scubaMode = true //ERROR: sketch/System.cpp:332: undefined reference to scubaMode' else scubaMode = false; //ERROR: sketch/System.cpp:334: undefined reference to
scubaMode'
#endif
** in alternator.cpp **
#include "Alternator.h"
**later in alternator.cpp **
if (tachMode) //NO ERROR HERE FOR tachMode
fieldPWMvalue = max(fieldPWMvalue, thresholdPWMvalue);
if(scubaMode) //ERROR: sketch/Alternator.cpp:1413: undefined reference to `scubaMode'
fieldPWMvalue = FIELD_PWM_SCUBA;
// END OF CODE SNIPPETS
Thank you!