什么是c ++中的SAL_CALL?

bal*_*aji 1 c c++ linux

任何人都可以简单解释一下.

什么是c ++中的SAL_CALL?

pax*_*blo 6

它是#define在OpenOffice.org中使用的.它被定义sal/inc/sal/types.h为以下之一:

#define SAL_CALL
#define SAL_CALL __cdecl
Run Code Online (Sandbox Code Playgroud)

取决于正在编译的平台.只有在_MSC_VER定义(对于Microsoft)时,它才会设置为后者.

在指定以下函数时使用它:

virtual void SAL_CALL acquire() throw () { ++m_nRefCount; }
Run Code Online (Sandbox Code Playgroud)

将变成:

virtual void acquire() throw () { ++m_nRefCount; }
Run Code Online (Sandbox Code Playgroud)

对于常规编译器和:

virtual void __cdecl acquire() throw () { ++m_nRefCount; }
Run Code Online (Sandbox Code Playgroud)

对于微软.

至于__cdeclMicrosoft编译器的含义,请参见此处,摘录如下:


微软特定

这是C和C++程序的默认调用约定.因为调用者清理了堆栈,所以它可以执行vararg功能.该__cdecl调用约定创建大于可执行文件__stdcall,因为它要求每个函数调用堆栈包括清理代码.以下列表显示了此调用约定的实现.


+------------------------+----------------------------+
| Element                | Implementation             |
+------------------------+----------------------------+
| Argument-passing order | Right to left              |
+------------------------+----------------------------+
| Stack-maintenance      | Calling function pops the  |
|   responsibility       |   arguments from the stack |
+------------------------+----------------------------+
| Name-decoration        | Underscore character (_)   |
|   convention           |   is prefixed to names     |
+------------------------+----------------------------+
| Case-translation       | No case translation        |
|   convention           |   performed                |
+------------------------+----------------------------+
Run Code Online (Sandbox Code Playgroud)