• Answer Suggested

CCS/TMS320F28377D: A question on C++ support in TMS320F28377D

Part Number: TMS320F28377D

Tool/software: Code Composer Studio

Dear C28X compiler Champs,

A customer has a question in compiling C++ code when using TMS320F28377D.

The compiler version is ti-cgt-c2000_15.12.4.LTS

The question is when the customer uses a virtual function, but the compiler report error:

The code is :

int priv_func(char *recMsg)

{

       recMsg = "\r\nHello World!\r\nNow test the F28377D printf! \n\0";

       scia_msg(recMsg);

 

       return 0;

}

 

struct myself_i {

       virtual int priv_func(const char const *recMsg) = 0;

};

 

void main(void)

{

       char *msg;

   struct myself_i mySelf;

。。。。。。。

//priv_func(msg);

 mySelf.priv_func(msg);

}

The compiler reports problems as follows: we have checked, there is ';'

Please kindly help to check and comments.

Thanks and best regards,

Hardy

  • I am not certain of the cause of the problem.  Here is my guess.

    I think the source file with the problem has the extension .c and not .cpp.  This means the compiler expects it to contain C source, and not C++ source.  You cannot use the keyword virtual in a C file, only in a C++ file.  If this is the problem, one possible fix is to change the file extension.  For more information on how the compiler uses file extensions, and how you can change that behavior, please see the section titled Specifying Filenames in the C2000 compiler manual.

    Thanks and regards,

    -George


    TI C/C++ Compiler Forum Moderator
    Please click Verify Answer on the best reply to your question
    The CCS Youtube Channel
     has short how-to videos
    The 
    Compiler Wiki answers most common questions
    Track an issue with SDOWP. Enter your bug id in the Search box.

  • In reply to George Mock:

    Hi George;
    First,thanks for solution this problem.I according to your means to solution this problem.cause of problem with the compiler force to distinguish C file(.c) and C++(.cpp), So cannot use the keyword virtual in a C file, only in a C++ file.