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.

Add a C++ file to the ccs v5 project

Other Parts Discussed in Thread: SYSBIOS

Hi,

I am using the C66x DSP and the CCS v5.0.3, I want to add a C++ file to the project. What should I notice?

I have added a .cpp file to the ccs project. 

However there are some questions as follow:

And my code as follow:

1263.code.rar

Thank you.

Tianxing

  • Try changing the #including source file's name to something.C (capital C) and see if that helps.

    If not, maybe your header is being compiled by itself (that should not happen..); if it is listed alongside the C and C++ source files, move it to the Includes folder instead.

  • Thank you for your answer.

    I have some questions.

    First, I try modify the c file to cpp file. And it would no error when I build the project, but it would errored when I load programming. The cmd file, tcf file and errors as follw:

    3527.linker_c6678.rar

    0385.tsuApp.rar

    5141.error.rar

    My question is that what should I do when I use the C++ class in my code. I try use the extern "C", but it can't resolve the class error. Maybe the compiler don't identify the extern "C".

    Second, it provide Language Options in CCS, if I can write code in C++ fully. And it provide option of Embedded C++, what affections would be if I choose the option.

    Tianxing

  • Hi, I have a question about the option of Embedded C++.

     I must choose the compiler option of -pe if I add a C++ file to my project? What's the mean of -pe?

    Tianxing

  • You only choose the -pe option if you want to specify Embedded C++ support, otherwise you don't need to. This wiki page explains what support for Embedded C++ means.

  • Hi Johannes,

    Thank you for your reply.

    I thought the reason of the error is the overflow of memory, And I change the cmd file, the code executed successful.

    If my files are .cpp, it would be no error even though I used the class.

    I call a function of class in the .c file according to the instruction of http://processors.wiki.ti.com/index.php/Invoke_a_C++_Class_Member_Function_from_an_Interrupt.

    Now I have a question about the name mangling.

    In the web of http://processors.wiki.ti.com/index.php/Overview_of_C++_Support_in_TI_Compilers#Name_Mangling. I see one feature of C++ is called function overloading because it can mangled the name of function. Now I have a question about that if I used the extern "c" in the C++ code, if it have the feature of function overloading, and if I define two function with the same name and the argument is different, it would be.

    Tianxing

  • extern "C" means the function has C "linkage", which means it can be called from C code.  The C code expects the function name will not be mangled, so extern "C" functions must not be mangled.  Therefore, you cannot overload extern "C" functions.