Go Down

Topic: #define not working [solved. my mistake] (Read 1 time) previous topic - next topic

Dec 13, 2006, 11:21 am Last Edit: Dec 13, 2006, 01:55 pm by twodotone Reason: 1
hi, guys.


I'm having a very weird issue with #define


in my app, I wanted to reduce the memory usage, and so I wrote this


Code: [Select]
#define CALIB1 0


void setup(){

}

void loop(){
  int an1=analogRead(CALIB1);
}


quite easy, right?

it should just convert CALIB1 to 0 on compile time.
why do I get this, then?

Code: [Select]
In function 'void loop()':
error: expected `)' before ';' token


if I use
Code: [Select]
int an1=analogRead(0);

then no  problem at all.
is this a bug in the IDE?
it's making me nuts.

thank you for helping.

ubi

Daniel

what version of the Arduino software are you using? It compiles fine for me in Arduino 006/MacOSX/Intel.


Done Compiling

Binary sketch size: 4242 bytes (of a 7168 byte maximum)

hey, daniel.

sorted that out.
in typing the code back in the forum post I typed it correctly.
the mistake was adding a semi-colon at the end of the define line.
this was causing the pre-compiler to create

Code: [Select]

int an1=analogRead(0;);



I should have realized that earlier reading the output message.
works for me too, of course.

thank you for the interest.

Go Up