代码之家  ›  专栏  ›  技术社区  ›  Ben Voigt

在VS2010中,abort()不是declspec(noreturn)

  •  16
  • Ben Voigt  · 技术社区  · 14 年前

    在我的VS2010副本中,stdlib.h包含(第353-355行)

    _CRTIMP __declspec(noreturn) void __cdecl exit(_In_ int _Code);
    _CRTIMP __declspec(noreturn) void __cdecl _exit(_In_ int _Code);
    _CRTIMP void __cdecl abort(void);
    

    我觉得奇怪的是没有 noreturn abort() . 有人知道原因吗?是虫子吗?

    编辑:在VS2008中,是相同的,但是stdlib.h的第371-373行

    缺乏 诺雷图恩 正在触发批注 error C4716 .

    C++0x proposal for standardization of the noreturn annotation ,也就是说 abort

    编辑:看起来一堆讨论都消失了,答案也被删除了,但其中的要点在 Defect Report #048

    1 回复  |  直到 14 年前
        1
  •  6
  •   Martin Ba    14 年前

    因此,由于uu declspec(noreturn)是一个实现的东西,并且由于在visualstudio中abort的实现永远不会正常返回,abort()应该被标记为u declspec(noreturn)。

    https://connect.microsoft.com/VisualStudio/