C. J. Clegg said:
Can I do this?
typedef struct _aStruct
{
int a;
long b;
char c;
} MYSTRUCT;
[...]
(As others have said, yes, C supports struct assignment.)
You should avoid using identifiers with leading underscores. If you
want to check the standard or a good reference, you can find out
exactly which forms are permitted in which circumstances, but it's
easier just to avoid declaring such identifiers altogether.
If you're going to declare two names for a struct type, there's no
need to use two different identifiers. For example, this is perfectly
legal:
typedef struct foo {
int a;
} foo;
The type now has two names, "struct foo" (the struct keyword followed
by the tag name) and "foo" (the typedef name). Since struct tags are
in their own namespace, they aren't going to conflict with anything
else.
If you want to use distinct identifiers for some reason (doing so
might make things easier in some programming environments), you can
establish some consistent convention to avoid the confusion of coming
up with two different names for the same thing (in your case,
"_aStruct" and "MYSTRUCT"):
typedef struct foo_s {
int a;
} foo;
Or you might consider just dropping the typedef altogether, since it
doesn't really add any value:
struct foo {
int a;
};
struct foo obj;
The latter is a matter of some controversy; plenty of people think
that the benefit of having a one-word name for the type is worth the
effort of adding a typedef.