Datasheet
Note that the structure tag can be omitted, but then additional objects of this type
cannot be declared elsewhere. For more information, see the Untagged Structures
below.
Structure is initialized by assigning it a comma-delimited sequence of values within
braces, similar to array. For example:
/* Referring to declarations from the example above: */
/* Declare and initialize dots p and q: */
struct Dot p = {1., 1.}, q = {3.7, -0.5};
/* Declare and initialize circle o1: */
struct Circle o1 = {1., {0., 0.}}; // radius is 1, center is at (0,
0)
Incomplete Declarations
Incomplete declarations are also known as forward declarations. A pointer to a
structure type A can legally appear in the declaration of another structure B before A
has been declared:
struct A; // incomplete
struct B {struct A *pa;};
struct A {struct B *pb;};
The first appearance of A is called incomplete because there is no definition for it at
that point. An incomplete declaration is allowed here, because the definition of B
doesn’t need the size of A.
Untagged Structures and Typedefs
If the structure tag is omitted, an untagged structure is created. The untagged struc-
tures can be used to declare the identifiers in the comma-delimited member-
declarator-list
to be of the given structure type (or derived from it), but addition-
al objects of this type cannot be declared elsewhere.
/* With tag: */
typedef struct mystruct { ... } Mystruct;
Mystruct s, *ps, arrs[10]; /* same as struct mystruct s, etc. */
/* Without tag: */
typedef struct { ... } Mystruct;
Mystruct s, *ps, arrs[10];
166
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroC PRO for AVR
CHAPTER 5