Open GoogleCodeExporter opened 9 years ago
The code below compiles and runs as expected. (Arduin 0017 IDE on Windows Vista
32 bit)
struct A_NEW_TYPE {
int a;
int b;
int c;
} foo;
void setup() {
Serial.begin(9600);
foo.a = 10;
}
void loop() {
dostuff(&foo);
delay(2000);
}
void dostuff(struct A_NEW_TYPE * bar) {
Serial.print("bar.a: ");
Serial.println(bar->a);
}
Though, when using the following code, it won't compile:
typedef struct A_NEW_TYPE {
int a;
int b;
int c;
} MY_NEW_TYPE;
MY_NEW_TYPE foo;
void setup() {
Serial.begin(9600);
foo.a = 10;
}
void loop() {
dostuff(&foo);
delay(2000);
}
void dostuff(MY_NEW_TYPE * bar) {
Serial.print("bar.a: ");
Serial.println(bar->a);
}
While changing the line
void dostuff(MY_NEW_TYPE * bar) {
to
void dostuff(struct A_NEW_TYPE * bar) {
makes it compile in Arduino IDE again.
Original comment by qistoph
on 20 Jan 2010 at 6:14
There is a patch here
https://github.com/EbiDK/Arduino/commit/96fc3c18c0cb118ec273947590e27114bfd7970d
that somewhat solves it. The problem is that generated prototypes get put at
the top of the file which is before the new type/struct is defined. This patch
skips generating prototypes for functions that already have prototypes in the
file, so if you just need to put in the prototype after the type/struct is
defined and the generator will skip generating that one.
Original comment by lars.j.n...@gmail.com
on 3 Mar 2012 at 6:58
See issue 973 for a work-around.
Original comment by dmel...@gmail.com
on 31 Jul 2012 at 12:46
Please give a try to the IDEs linked at the bottom of this email on the dev list
https://groups.google.com/a/arduino.cc/forum/#!msg/developers/4X2T3rCxXWM/YNJl6P
ZuDucJ
We're testing a new preprocessor and it compiles your sketch just fine.
Original comment by federico...@gmail.com
on 28 Jan 2015 at 4:17
New preprocessor tracked at https://github.com/arduino/Arduino/pull/2636.
Builds for testing it are available
Original comment by federico...@gmail.com
on 13 Feb 2015 at 7:20
Original issue reported on code.google.com by
lex.v.ta...@gmail.com
on 19 Jan 2010 at 10:48