Pages: [1]   Go Down
Author Topic: What is the 'config_t'?  (Read 2975 times)
0 Members and 1 Guest are viewing this topic.
South East USA
Offline Offline
God Member
*****
Karma: 5
Posts: 658
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code I'm working with:
http://www.arduino.cc/playground/Code/EEPROMWriteAnything

I know it works, but if I can understand HOW, it'll be way better. So...
There's no mention of 'struct' in the reference pages, but I understand that it makes something like a group variable.  What is the 'config_t'?  I couldn't find much googling it.
struct config_t
{
    long alarm;
    int mode;
} configuration;

Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It's called a "tag".  It's somewhat like a typedef.  It allows you to create multiple instances of the structure...

struct config_t ConfigLoadedFromStorage;

struct config_t UserModifiableConfig;
Logged

South East USA
Offline Offline
God Member
*****
Karma: 5
Posts: 658
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah, I got, after looking up 'tag', this is very clear:
http://www.exforsys.com/tutorials/c-language/c-structures-and-unions.html

...so it's optional.
Logged

South East USA
Offline Offline
God Member
*****
Karma: 5
Posts: 658
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...no, it doesn't seem to be optional like that webpage says, at least it doesn't compile without it.
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It is optional.  This compiles without error...

Code:
struct
{
    long alarm;
    int mode;
} configuration;

void setup( void )
{
}

void loop( void )
{
}
Logged

Pages: [1]   Go Up
Jump to: