有没有人能简单地解释一下。
什么是c++中的SAL_CALL?
发布于 2011-02-24 14:45:59
它是OpenOffice.org中使用的#define。它在sal/inc/sal/types.h中定义为以下内容之一:
#define SAL_CALL
#define SAL_CALL __cdecl这取决于要为其编译的平台。看起来只有在定义了_MSC_VER (用于微软)的情况下,它才会被设置为后者。
在指定如下函数时使用:
virtual void SAL_CALL acquire() throw () { ++m_nRefCount; }它将被变形为:
virtual void acquire() throw () { ++m_nRefCount; }对于常规编译器和:
virtual void __cdecl acquire() throw () { ++m_nRefCount; }对微软来说。
关于__cdecl对微软编译器的意义,请参阅here,摘录如下:
特定于微软的
这是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 |
+------------------------+----------------------------+发布于 2011-02-24 14:40:17
这对C++来说并没有什么特别之处。它是某种特定于项目的预处理器宏。我猜这是某种特殊的调用约定。我发现了one preprocessor macro in the Linux kernel,它似乎是一种64位优化的调用约定。根据该文件顶部的注释,"SAL“代表”系统抽象层“。
https://stackoverflow.com/questions/5101182
复制相似问题