Dear Forum
when a compile is attempted on the sketch which includes the following code. The error as pasted below results.
ISR (ANALOG_COMP_vect)
{
triggered = true;
};
//maketimer
struct makeTimer
{
#define MILLIS true
#define MICROS false
public:
unsigned long StartTime;
unsigned long Interval;
bool Restart;
bool EnableFlag;
bool TimerType;
};
"MakeTimer not declared in scope"
Compiling sketch...
"/home/ubuntu/opt/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-I/home/ubuntu/opt/cores/arduino/avr/cores/arduino" "-I/home/ubuntu/opt/cores/arduino/avr/variants/standard" "/tmp/766335412/build/sketch/sketch_may10a.ino.cpp" -o "/tmp/766335412/build/sketch/sketch_may10a.ino.cpp.o"
/tmp/766335412/sketch_may10a/sketch_may10a.ino:134:20: error: 'makeTimer' was not declared in this scope
/tmp/766335412/sketch_may10a/sketch_may10a.ino:134:31: error: 'TimerX' was not declared in this scope
/tmp/766335412/sketch_may10a/sketch_may10a.ino: In function 'void loop()':
/tmp/766335412/sketch_may10a/sketch_may10a.ino:124:23: error: 'CheckTimer' cannot be used as a function
/tmp/766335412/sketch_may10a/sketch_may10a.ino: In function 'boolean CheckTimer(makeTimer&)':
/tmp/766335412/sketch_may10a/sketch_may10a.ino:134:37: error: 'boolean CheckTimer(makeTimer&)' redeclared as different kind of symbol
/tmp/766335412/sketch_may10a/sketch_may10a.ino:134:9: note: previous declaration 'boolean CheckTimer'
/tmp/766335412/sketch_may10a/sketch_may10a.ino: In function 'void StateMachine()':
/tmp/766335412/sketch_may10a/sketch_may10a.ino:174:26: error: 'CheckTimer' cannot be used as a function
/tmp/766335412/sketch_may10a/sketch_may10a.ino:189:26: error: 'CheckTimer' cannot be used as a function
/tmp/766335412/sketch_may10a/sketch_may10a.ino:197:26: error: 'CheckTimer' cannot be used as a function
/tmp/766335412/sketch_may10a/sketch_may10a.ino:212:26: error: 'CheckTimer' cannot be used as a function
/tmp/766335412/sketch_may10a/sketch_may10a.ino:220:26: error: 'CheckTimer' cannot be used as a function
exit status 1
HOWEVER:
When the code is reordered as below then the code compiles with no error.
//maketimer
struct makeTimer
{
#define MILLIS true
#define MICROS false
public:
unsigned long StartTime;
unsigned long Interval;
bool Restart;
bool EnableFlag;
bool TimerType;
};
ISR (ANALOG_COMP_vect)
{
triggered = true;
};
Thank you for any explanation?