I'm trying figure out how to declare and enumeration in the *.ino file
My code so far is as follows:
//in global space
enum Mode {
SingleTone = 0, UnRampedFSK = 1, RampedFSK = 2, Chirp =3, BPSK = 4
};
// using it like this in a function definition;
void setModeData(byte Address, enum SingleTone){
setAddrress( Address, 23);
setData( Mode);
};
No matter what I try I'm getting:
"sketch_jun03a:9:39: error: use of enum 'SingleTone' without previous declaration"
The language reference does not cover this!!
enum Mode {
SingleTone = 0, UnRampedFSK = 1, RampedFSK = 2, Chirp =3, BPSK = 4
};
// using it like this in a function definition;
void setModeData(byte Address, Mode widgetMode){
setAddrress( Address, 23);
setData( widgetMode);
};
Language references explain what is correct syntax and usage. You can't expect the compiler to work backwards from the billions of ways in which programmers could deviate from it, and produce a targeted error message for each one. It can only flag the symptom, and let you figure out why your code exhibits it.
Often when using enum in a function declaration, you will need to provide the function prototype, the compiler is placing the auto-generated prototype before the enum.
Regarding the question about why I'm trying to use the an enum. I want to use a parameter such as :
Mode.SingleTone to be specific which mode it is. otherwise I'd have to use a number such as 0, 1, 2, 3, or 4
Thanks wildbill and aarg: I think I know now why I'm getting the problem, enum is a "type" duh.
Great.