Problem with Program: HELP!


I am getting strange errors with my program. Here they are.

Scheduler.cpp:17: error: new types may not be defined in a return type
Scheduler.cpp:17: error: two or more data types in declaration of ‘AddTask’

Attached are the files for my program. How can I fix these problems?

Unos_0_1_2.ino (278 Bytes)

Timer.h (1.1 KB)

Timer.cpp (1.03 KB)

Scheduler.h (1.15 KB)

Scheduler.cpp (1.63 KB)

Why are you declaring this in every function?

Scheduler Task;

Do you know about scope and passing variables?

Well, where am I supposed to declare an instance of Scheduler in order to call functions?

Declare it globally.

It seems you need a book on programming to understand how variables work. One of the many things to learn: variables declared within a {} block only exist within that block.

Yes, I know that part about scope. Thanks.

    // This variable is used in Time() and is the amount of time for waiting in milliseconds.
    unsigned long TIME_NEEDED;

We are getting REALLY tired of telling you that all capital letter names are reserved for CONSTANTS. Get with the program or get out of here!

OK. Now I get these errors.

Unos_0_1_2.ino:20: error: multiple definition of `Task’
Scheduler.cpp:19: first defined here

Unos_0_1_2.ino (282 Bytes)

Scheduler.h (1.16 KB)

Scheduler.cpp (1.54 KB)

Timer.h (1.1 KB)

Timer.cpp (1.03 KB)

int Timer::Time(unsigned long TIME_NEEDED)

The value passed to this function is not used. Why does it take an argument?


OK. I fixed that. But what I really wanted to fix was those pesky compiler errors.

Scheduler Task;

This is the last line in Scheduler.h. It needs to be in the .cpp file instead.

I had to add this to the .ino

extern Scheduler Task;

and it compiled fine.

Thank you so much, Delta_G!