Go Down

Topic: structures and pointers (Read 913 times) previous topic - next topic

cappy2112



I don't see structs/unions nor pointers in the compiler reference.
Please, someone tell me this compiler supports structures and pointers.


Arduino Reference (extended)

The Arduino language is based on C/C++ and supports all standard C constructs and some C++ features. It links against AVR Libc and allows the use of any of its functions; see its user manual for details.

westfw

Yes, of course it supports pointers and structures.  Here's a snip from some menu code I wrote (which appears to work.)

Code: [Select]
typedef void * menu_action_t;

typedef const struct menu_item_ {
   unsigned char menu_key;
   menu_action_t menu_action;      /* function or menu pointer */
} menu_item_t;

mem

The Arduino uses the GCC compiler, which is ISO 90 compliant so as westfw says, you get full support for the C language including structures and unions.

You can find the documentation on the compile includingISO compliance documentation here: http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/

When I first came across the Arduino, I was surprised that the underlying language was a complete implementation of C and C++. There is little clue to that in the Arduino documentation, perhaps so as not scare away beginners to programming. But so far the compiler has coped with every C and C++ construct that I have thrown into my sketches.

cappy2112

Quote
The Arduino uses the GCC compiler, which is ISO 90 compliant so as westfw says, you get full support for the C language including structures and unions.

There is little clue to that in the Arduino documentation, perhaps so as not scare away beginners to programming. But so far the compiler has coped with every C and C++ construct that I have thrown into my sketches.


Yes, that is correct. Well, I'm glad to see it supports full C capabilities.
Can't live without structures and pointers


Thanks for clarifying

westfw

Quote
I was surprised that the underlying language was a complete implementation of C and C++. There is little clue to that in the Arduino documentation, perhaps so as not scare away beginners to programming.

I don't recall exactly how I came across arduino, but I always knew that gcc was underneath (and not "deep", either.)  I think the "C subset" structure is a wonderful idea, and of course I like having full C available for the more complex things that I'm used to.

Go Up