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 />
int f(){<br />
S s(2);<br />
cfunc(&s);<br />
return s.i * 3;<br />
}<br />
// initialize 's'<br />
// call 'cfunc' so it can change 's'<br />
示 例 5-13 定 义 C 语 言 函 数<br />
struct S {<br />
int i;<br />
};<br />
void cfunc(struct S *p) {<br />
/* the definition of the C function to be called from C++ */<br />
p->i += 5;<br />
}<br />
从 C++ 调 用 汇 编 语 言<br />
示 例 5-14 和 第 5-25 页 的 示 例 5-15 显 示 如 何 从 C++ 调 用 汇 编 语 言 。<br />
示 例 5-14 从 C++ 调 用 汇 编 语 言<br />
struct S { // has no base classes<br />
// or virtual functions<br />
S(int s) : i(s) { }<br />
int i;<br />
};<br />
extern "C" void asmfunc(S *);<br />
int f() {<br />
S s(2);<br />
asmfunc(&s);<br />
return s.i * 3;<br />
}<br />
// declare the Asm function<br />
// to be called<br />
// initialize 's'<br />
// call 'asmfunc' so it<br />
// can change 's'<br />
5-24 © 2002、 2003 <strong>ARM</strong> Limited 版 权 所 有 。 保 留 所 有 权 利 。 <strong>ARM</strong> DUI 0203BSC