C 函数中调用 C++函数 | |
class class1 { int getI(void); #endif // cpp.cpp using namespace std; // 打开标准库名字空间 class1::class1() class1::~class1() int class1::getI(void) // 按 C 调用方式编译下面函数 cout << "c++: " << pClass1->getI() << endl; return pClass1->getI(); // end file // c.h #ifdef __cplusplus typedef struct { #ifdef __cplusplus // c.c extern int get_class1_I(void * p); struct1 s; int main(void) // end file 参考了eCos中的混和编程实现方式(http://sources.redhat.com/ecos/)。 本例在ADS 1.2中编译通过,执行结果正确。 |