Device Monitoring Studio - Monitor, log and analyze data coming through PC ports and connections
Download Device Monitoring Studio Hide this button

Forward Declarations

Device Monitoring Studio Neo requires that each referenced type must be defined before it is used; otherwise, the compile-time error occurs. Sometimes it is impossible or inconvenient to follow this rule. Forward declarations allow you to declare the identifier as a user-defined type, without actually defining it:

struct B;         // forward declaration of B

struct A
{
    B b;          // compiles OK, as B has been declared
};

struct B          // actually define B
{
    // …
};

Syntax:

(struct | union | case_union) name-id ;        

name-id is required in forward declarations.

All forward declarations must be resolved before the end of the source file, otherwise an error occurs. However, it is not an error not to resolve a forward declaration if it has not been referenced.