User manual

Table Of Contents
mikroC PRO for PIC32
MikroElektronika
211
Also, a structure can contain previously dened structure types when declaring an instance of declared structure. Here
is an example:
/* Structure dening a dot: */
struct Dot {oat x, y;};
/* Structure dening a circle: */
struct Circle {
oat r;
struct Dot center;
} o1, o2;
/* declare variables o1 and o2 of Circle */
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 rst appearance of A is called incomplete because there is no denition for it at that point. An incomplete declaration
is allowed here, because the denition of B doesn’t need the size of A.