This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Why CCS v6.01 will not inherit base class variables and functions while CCS v5.2 does?

Other Parts Discussed in Thread: TM4C123GH6PM

I am porting my code from .c to .cpp, converting the functions into class functions. in code composer v5.2 this works quite well. However in code composer v6.01 both data variables and functions are not inherited. Please advise how this problem can be solved. Is there some compiler setting or directive that must be set?

Thank you for advise/guidance to solve this problem..

John

 

  • Hello John
    Moving it to CCS Forum
    Regards
    Amit
  • John Chee said:
    However in code composer v6.01 both data variables and functions are not inherited.

    Could you please elaborate a bit more on this? If you could provide a specific example, that would be helpful.

  • Here is the test code I used for checking out inheritance for TIVA TM4C123GH6PM. I created an empty ccs project and added a new .cpp source file in CCS v6.0.1.00040 . In the source file I declared a base class and also a child class that inherits the base class. The child class should therefore have one inherited data variable and one inherited function, in addition to its own data variable and function.

    However, after declaring an instance of the child class, I can only see the data variable and the function belonging to the child class only. Those that should be inherited from the base class cannot be seen. (in CCS v5.5.0.00077, (sorry not v5.2) this same code works.) Is there some compiler setting that needs to be set in CCS v6.01? Please assist. Thanks!



    #include <stdint.h>
    #include <stdbool.h>

    //-----------------------------------------------------------------------------
    class cl_base{
    public:
    uint8_t ui8Base_Data;
    void doBaseFunc(void);
    };
    //-----------------------------------------------------------------------------
    class cl_child:cl_base{
    public:
    uint8_t ui8Child_Data;
    void doChildFunc(void);

    };
    //-----------------------------------------------------------------------------
    //=============================================================================
    int main(void) {
    cl_child ChildObj;
    ChildObj.ui8Child_Data=0;
    ChildObj.doChildFunc();

    return 0;
    }
    //=============================================================================
    //-----------------------------------------------------------------------------
    void cl_base::doBaseFunc(void){
    ui8Base_Data = 5;
    }
    //-----------------------------------------------------------------------------
    void cl_child::doChildFunc(void){
    ui8Child_Data++;
    }
    //-----------------------------------------------------------------------------
  • Are you referring to problems with the auto complete feature in CCS when editing the code, or compiler errors that you are getting?
  • John Chee said:

    However, after declaring an instance of the child class, I can only see the data variable and the function belonging to the child class only.

    ...
    //-----------------------------------------------------------------------------
    class cl_child:cl_base{
    public:
    uint8_t ui8Child_Data;
    void doChildFunc(void);

    };

    I'll just point out that you are inheriting privately from cl_base.  So if by "I can only see", you mean something like "I can only access from main", that would be expected.  If this is the issue, then public inheritance might get you what you need.  e.g.

    class cl_child : public cl_base {

  • Thank you for your advise. Adding "public" before inheriting the base class works! ..although in Code Composer version 5.5 I need not do that...