Pages: [1]   Go Down
Author Topic: #define not working [solved. my mistake]  (Read 1137 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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:
In function 'void loop()':
error: expected `)' before ';' token

if I use
Code:
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
« Last Edit: December 13, 2006, 07:55:49 am by twodotone » Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
Logged

Pages: [1]   Go Up
Jump to: