请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:TMS320F28379D 工具/软件:TI C/C++编译器
大家好、团队、
您好!
保持安全和健康。
我可以在 CCS 中编写源代码时使用 C 和 C++组合吗? 我还想使用 C++、但无法用 C++编写整个代码、因为我对 C++不是很专业、所以我想探索 c 和 c++编码的组合。
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.
工具/软件:TI C/C++编译器
大家好、团队、
您好!
保持安全和健康。
我可以在 CCS 中编写源代码时使用 C 和 C++组合吗? 我还想使用 C++、但无法用 C++编写整个代码、因为我对 C++不是很专业、所以我想探索 c 和 c++编码的组合。
您好!
尝试以下操作:
// C++ code extern "C" void f(int); // one way extern "C" { // another way int g(double); double h(); }; void code(int i, double d) { f(i); int ii = g(d); double dd = h(); // ... } /* C code: */ void f(int i) { /* ... */ } int g(double d) { /* ... */ } double h() { /* ... */ }这是:
// C++ code: extern "C" void f(int); void f(int i) { // ... } /* C code: */ void f(int); void cc(int i) { f(i); /* ... */ }如果要从 C 调用成员函数、则需要为所有必需的函数提供简单的包装程序。