Which one are you intending to use? The distinction is important.
> I am coming from the world of Modula-2 and
> Ada and I'm trying to understand the following syntax
>
> typedef struct _win_border_struct
> {
> chtype ls,rs,ts,bs,tl,tr,bl,br;
> } WIN_BORDER;
In C++, the typedef is unnecessary clutter, just write
struct WIN_BORDER
{
chtype ls,rs,ts,bs,tl,tr,bl,br;
};
Note many coding standards reserve all cast for macro names, not
class/struct names.
In C, things are somewhat more complex, struct declarations live in
their own pseudo namespace and a typedef is required to map them into
the "global" namespace (C doesn't actually have namespaces, but this is
the easiest way to describe the rules).
If you were to use your original struct definition above, you would need
to explicitly name WIN_BORDER as a struct:
struct _win_border_struct border;
Adding the typedef allows you to write
WIN_BORDER border;
The "typedef struct" syntax is a shorthand for
struct _win_border_struct
{
chtype ls,rs,ts,bs,tl,tr,bl,br;
};
typedef struct _win_border_struct WIN_BORDER;
--
Ian Collins