This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Class forward declaration with RealView Compiler

Hello,

i have a question related to Realview Compiler V3.0.
Is the forward declaration of a class not supported or
is it a mistake of me?
Please look the example below:

class clsB;     // Forward Declaration  Not Working


class clsA
{
  public:
        clsA();         // Constructor

        clsB  oB;       // Compiler error:  #70: incomplete type is not allowed
};




class clsB
{
  public:
        clsB();         // Constructor
};

Thank you
Eugen

Parents
  • The forward declaration worked fine. It is the use of the incomplete type that is not allowed.

    class clsA
    {
      public:
            clsA();         // Constructor
    
            clsB  oB;       // Compiler error:  #70: incomplete type is not allowed
    };
    

    Is not allowed (because it needs to know the full type of claB)

    class clsA
    {
      public:
            clsA();         // Constructor
    
            clsB  *oB;       // No Compiler error:
    };
    

    Is allowed because it does not need to know the full type of claB at this point.

Reply
  • The forward declaration worked fine. It is the use of the incomplete type that is not allowed.

    class clsA
    {
      public:
            clsA();         // Constructor
    
            clsB  oB;       // Compiler error:  #70: incomplete type is not allowed
    };
    

    Is not allowed (because it needs to know the full type of claB)

    class clsA
    {
      public:
            clsA();         // Constructor
    
            clsB  *oB;       // No Compiler error:
    };
    

    Is allowed because it does not need to know the full type of claB at this point.

Children
No data