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.

Compiler/TMS320F28379D: Can I write the C & C++ both mix coding in CCS

Part Number: TMS320F28379D

Tool/software: TI C/C++ Compiler

Hello Team,

Greetings!

Stay safe and healthy.

Can I use C & C++ mix while writing the source code in CCS? I want use C++ as well but I can not write entire code in C++ as I am not expert in C++ therefore I want to explore mix of c and c++ coding.

  • Hello, 

    try this:

    1. // C++ code
    2. extern "C" void f(int); // one way
    3. extern "C" { // another way
    4. int g(double);
    5. double h();
    6. };
    7. void code(int i, double d)
    8. {
    9. f(i);
    10. int ii = g(d);
    11. double dd = h();
    12. // ...
    13. }
    1. /* C code: */
    2. void f(int i)
    3. {
    4. /* ... */
    5. }
    6. int g(double d)
    7. {
    8. /* ... */
    9. }
    10. double h()
    11. {
    12. /* ... */
    13. }

    and this: 

    1. // C++ code:
    2. extern "C" void f(int);
    3. void f(int i)
    4. {
    5. // ...
    6. }
    1. /* C code: */
    2. void f(int);
    3. void cc(int i)
    4. {
    5. f(i);
    6. /* ... */
    7. }

    If you want to call member functions from C, you need to provide simple wrappers for all required functions. 

  • For further suggestions on how to mix C and C++ code, please see this FAQ (not from TI).

    Thanks and regards,

    -George

  • Hi Tom,

    Good Day!

    Stay safe and healthy.

    Thanks for your post.

    Please you elaborate more on this topic. Do you mean to say that only I need to declare the functions what you have declared in your post.

    Is there any document is available for this topic (Mix coding c and C++ in CCS IDE. Is there anything I need to install or declare or called while using C++ functionality?

  • Hi Gorge,

    Good Day!

    Stay safe and healthy.

    Thanks for sharing the link. I think this will help me to understand the mix of C and C++ coding.

    I will study and analyse the link details and update you in this topic.