RealView Compilation Tools Developer Guide - ARM Information ...
RealView Compilation Tools Developer Guide - ARM Information ...
RealView Compilation Tools Developer Guide - ARM Information ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
混 合 使 用 C、C++ 和 汇 编 语 言<br />
在 C 和 C++ 之 间 传 递 引 用<br />
示 例 5-20 和 示 例 5-21 显 示 如 何 在 C 和 C++ 之 间 传 递 引 用 。<br />
示 例 5-20 C++ 函 数<br />
extern "C" int cfunc(const int&);<br />
// Declaration of the C function to be called from C++<br />
extern "C" int cppfunc(const int& r) {<br />
// Definition of the C++ to be called from C.<br />
return 7 * r;<br />
}<br />
int f() {<br />
int i = 3;<br />
return cfunc(i);<br />
}<br />
// passes a pointer to 'i'<br />
示 例 5-21 定 义 C 函 数<br />
extern int cppfunc(const int*);<br />
/* declaration of the C++ to be called from C */<br />
int cfunc(const int* p) {<br />
/* definition of the C function to be called from C++ */<br />
int k = *p + 4;<br />
return cppfunc(&k);<br />
}<br />
<strong>ARM</strong> DUI 0203BSC © 2002、 2003 <strong>ARM</strong> Limited 版 权 所 有 。 保 留 所 有 权 利 。 5-27