【问题标题】:Unusual C function declaration不寻常的 C 函数声明
【发布时间】:2016-05-20 09:47:40
【问题描述】:

我目前正在使用一个旧的 C 库(在 90 年代初期制作),下面的函数声明让我感到困惑:

#define bland_dll
typedef unsigned short int usint;
typedef unsigned char uchar;

int bland_dll Read_Chan (usint channel);

bland_dll 在函数名和返回类型之间做了什么?

谢谢你的灯!

【问题讨论】:

标签: c function declaration


【解决方案1】:

它是一个定义空的宏,所以经过预处理后结果是:

int Read_Chan (usint channel);

我怀疑,它是早期声明 DLL 链接类型时的保留,例如 pascal,它对链接器具有特殊含义。另一个例子是__cdecl

为了完成编译器链接机制的特性:

  1. __stdcall
  2. __fastcall
  3. __cdecl

它们中的每一个都影响了链接器在编译时管理名称修饰的方式,并且可能由于不同的链接时间切换而导致与第三方 DLL 的链接发生冲突。

编辑:感谢 unwind 的更正。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多