the whole point is data encapsulation, so it needs to be what it is, I know there is 100 different solutions. Also wrapping the definition inside extern "C" doesn't work
I am again sad to see the arduino IDE differs from well established standards.
I think I am going to test code::blocks as sketch IDE.
Trying to compile that line of code with my "normal" C and C++ compilers failed as well. I use gcc version 4.6.3. You may want to re-think your assertion that all normal C compilers don't have a problem with that specific code.
One of the brilliant decisions that the Arduino implementers made was to not create their own language. They used the tried and trusted C++ language, and even used tried and trusted compilers. I have no "Arduino compiler". The Arduino IDE invokes the C++ tool chain I already have on my machine. Granted it has to have the ability to put out AVR machine code, but that's independent of the parsing.
Fighting with the compiler is nothing new to programmers. I think you have a few of options here.
Figure out how to fix your code so that the compiler that your IDE is invoking will accept it.
Figure out how to get the compiler that your IDE is invoking to accept that code. If stowite is correct, and the latest version of avr-g++ works with that code but not when invoked through the IDE, it could be an issue of compiler options.
Figure out why the compiler that your IDE is invoking doesn't accept that code, and fix the compiler. It is Open Source, after all.
Figure out how to get your IDE to invoke one of the "normal" compilers that you have that will accept that code.
Get a new IDE
Don't use an IDE
Ah... options. That's one thing I really love about the Arduino system. I can customize it however I want.
This is strictly a matter of differences between C and C++.
The Arduino IDE has nothing to do with it.
C
struct Foo { ... };
struct Foo foo1; 'struct' required
Foo foo2; error: type Foo not defined
typedef struct Foo { ... } *Foo; OK: Foo and struct Foo are separate things
C++
struct Foo { ... };
struct Foo foo1; 'struct' optional
Foo foo2; same as 'struct Foo foo2;'
typedef struct Foo { ... } *Foo; error: conflicting definitions for type Foo
It's because the arduino is a C++ compiler, not a C compiler. In C++, a struct declaration also declares the bare name as an identifier. In C, you always have to use "struct Foo", so there's no conflict.
we always used a locally-standardized syntax for struct typedefs, something like:
typedef struct foo_ { .... } foo_t;
:
foo_t foo;
(this pre-dates "anonymous structures" by a long time, and keeps the structure name (foo_), the type (foo_t) and the actual variable all nicely distinguished from one another.)