2.11 Forward References

Once declared, identifiers can be used freely. Using an identifier before its declaration is called a forward reference, and results in an error, except in the following cases:

Here are some examples of valid and invalid forward references:

int a;
main ()
{
 int b = c;           /*  Forward reference to c -- illegal         */
 int c = 10;
 glop x = 1;          /*  Forward reference to glop type -- illegal */
 typedef int glop;
 goto test;           /*  Forward reference to statement label --
                          legal                                     */
test:
 if (a > 0 ) b = TRUE;
}

The following example shows the use of a structure tag in a forward reference:

struct s
  { struct t *pt };    /*  Forward reference to structure t         */
.                      /* (Note that the reference is preceded      */
.                      /* by the  struct keyword to resolve         */
.                      /* potential ambiguity)                      */
struct t
   { struct s *ps };


Previous Page | Next Page | Table of Contents | Index