Reserved words

I'm a newcomer to Arduino software and just spent a whole day finding that a bug in my program producing an incomprehensible (to me) compiler error was solved by changing the name of a constant from "timeout" to "timeup". So I conclude that the former is a reserved word. The editor gave no clue. It must be in avr-gcc since I'm using no libraries. Where do I find a list of reserved words so I don't have to suffer through this in the future? Are there other programming techniques to avoid this mistake?

Nope, not a reserved word, though it could be a global variable (unlikely).
Why don't you post your code, or the error message?

Or both. The terms listed on this page:

and this page:

are reserved.

Here's the problem code, reduced to it's essence.

#define timeout 200

int count;

void setup()

void loop()

When verified, it gives the following message:

/Applications/ error: expected ',' or '...' before numeric constant

/Applications/ error: expected ',' or '...' before numeric constant

If you change the word "timeout" to "timeup" it verifies with no messages.

#define is a C preprocessor directive, a primitive macro substitution language.

You said:

#define timeout 200

In wiring.h on line 119 it says:

unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);

After the preprocessor has finished the compiler will get this:

unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long 200);

That's illegal syntax. To avoid problems like this, adopt a strategy in your #define naming that is unlikely to clash with anything in the libraries that you are using. e.g.


Better still, don't use the C preprocessor at all and encapsulate your constants within the class implementing the code that uses them:

class whatever
  static const int Timeout=200;

And access it like this:

int theTimeout = whatever::Timeout;

There is a convention that #defined terms be all upper case letters

#define TIMEOUT 200

This would not have clashed with the argument name in wiring.h.

As you've discovered, there's a reason for conventions.

My thanks to Andy Brown and PaulS. I'm still too much of a Newbie to even comprehend what Andy said. My knowledge of C is limited to what I read in Kernighan & Ritchie. Thus far, I haven't even been able to find wiring.h on my Mac and suspect there are lots of other reserved words there and maybe in other files I don't know about. I have no idea how to not use the preprocessor. It seems hiding all this stuff doesn't really make Arduino easier. But I can certainly apply the ALL CAPS convention.

Can you suggest where I can go to read about things like the all-caps convention and the stuff Andy is talking about.