i'd like to adapt for the 1.9 branch the GTK and GLib custom of writing structs and data types capitalized LikeThisIsWritten, and functions, variables and struct members underscore-separated and lower case, like_this_is_written.
this makes the code a bit more readable. if you hack around in 1.9, please try to adhere to this custom. e.g., geovah has a variable named teamID in his season objective patch, which would violate the custom; this isn't important in 1.7, but let's do it in 1.9.
in case you have even better suggestions on style, let me know
gyözö
coding style
coding style
Press any key to continue or any other key to quit.
structs
i've also just found out that there's a shorter way to define handy structs. instead of i can write no doubt geovah already knew this but didn't bother to tell me
gyözö
Code: Select all
typedef struct _Cup Cup;
struct _Cup
{
gint id;
...
};
Code: Select all
typedef struct {
gint id;
...
} Cup;
gyözö
Press any key to continue or any other key to quit.
Re: structs
Because there is some advantage to use the first (can't find good information/documentation about it on internet).gyboth wrote:i've also just found out that there's a shorter way to define handy structs. instead ofi can writeCode: Select all
typedef struct _Cup Cup; struct _Cup { gint id; ... };
no doubt geovah already knew this but didn't bother to tell meCode: Select all
typedef struct { gint id; ... } Cup;
gyözö
So this is an example :
Code: Select all
file toto.h
typedef struct _info toto;
void dummy1(toto * dummy);
toto * dummy2(int dummy);
Code: Select all
file toto.c
struct _info {
int one;
};
void dummy1(toto * dummy) {
printf("%d",dummy->one);
}
toto * dummy2(int dummy) {
toto*res=malloc(sizeof(struct _info));
res->one=dummy;
return res;
}