为什么微软仍然支持nothrownew.obj?

发布于 2024-12-18 15:26:57 字数 534 浏览 0 评论 0原文

根据 MSDN,Microsoft 仍然随 Visual C++ 10 提供 nothrownew.obj (Visual Studio 2010) 运行时库,以便用户可以链接到它并具有“普通”(不是 nothrow 风格)new 返回 null 的不标准行为关于分配失败。这种不合标准的行为可以追溯到 Visual C++ 6,现在它被认为是非常古老的。

为什么会这样做呢?我的意思是他们使编译器的每个新版本越来越符合标准。例如,Visual C++ 7 支持“default int”,但 Visual C++ 9 则不支持。通过稍微更改代码以使用 newnothrow 风格,可以轻松实现 new 的旧的不合标准行为 - 这是简单且非常简单的简单的。

为什么这个选项如此重要以至于 Microsoft 仍然支持它?

According to MSDN, Microsoft still ships nothrownew.obj with the Visual C++ 10 (Visual Studio 2010) runtime library, so that users can link against it and have sub-standard behavior of "ordinary" (not nothrow flavor) new returning null on allocation failure. This sub-standard behavior dates back to Visual C++ 6 which is now considered extremely old.

Why would it do so? I mean they make each new version of the compiler more and more Standard-compliant. For example, Visual C++ 7 would support "default int", but Visual C++ 9 would not. And the old sub-standard behavior of new can be easily achieved by slightly changing code to use nothrow flavor of new - this is straightforward and very easy.

Why is this option so important that Microsoft still supports it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无风消散 2024-12-25 15:26:57

嗯,这是一个悬而未决的问题,因为除了微软的负责人之外,没有人可以肯定地说——如果有的话。所以,我会咬一口:

我猜这是为了方便:

  1. 微软本身可能在他们的某些产品中需要它,并且将它与编译器工具一起使用会更容易。
  2. 微软可能知道有人(比如大供应商/应用程序)仍然需要它,并且仍然提供它只是更容易(或者甚至是必要的,如果编译器特定)。
  3. 微软可能知道/预计它通常仍然在遗留应用程序中“广泛”使用。大或小。
  4. “它不疼”,这是有道理的。例如,Microsoft 在保持 Windows 向后兼容性方面有着悠久的记录(请参阅 Raymond Chen 的博客)再说一遍,可以说并不总是更好。
  5. 文档、测试等需要更改(或删除,但仍然如此)。

也就是说,删除它可能比保留它更麻烦。

至少他们需要/应该在删除版本之前提供已弃用的通知。我不知道他们是否在 VS2010 或任何之前的版本中这样做。

Well, this is sort of an open question, since nobody except someone responsible from Microsoft can say for sure - if at all. So, I'll take a bite:

I'll guess it is for convenience:

  1. Microsoft itself may need it in some of their products and it is just easier having it together with the compiler tools.
  2. Microsoft may know that someone (say a big vendor/app) still needs it and it is just easier (or even necessary if compiler specific) to still provide it.
  3. Microsoft may know/anticipate that it is generally still "widely" used in legacy apps. Big or small.
  4. "It doesn't hurt", well arguably. For example, Microsoft has a long record of maintaining backward compatibility in Windows (see Raymond Chens blog), again, arguably not always for the better.
  5. Documentation, Tests, etc. would need to be altered (or removed, but still).

That is, removing it may be more trouble yet then just keeping it.

At least they need / should provide a deprecated notice a version prior to removing it. I don't know if they did that for VS2010 or any prior version.

过度放纵 2024-12-25 15:26:57

因为我现在(2012 年)将产品从 Visual C++ 6.0 移植到 Visual Studio 2010,这对加快开发速度有很大帮助。我们也不会在未来几年内进行 Unicode 过渡。如果微软不提供兼容性功能,我会自己构建它。

附带说明一下,我们是专业领域的主要 ISV。如果我们决定改变操作系统,整个行业可能都会改变。 (在 Windows 之前,我们也曾经构建过专门的操作系统。)

Because I am now (2012) porting a product from Visual C++ 6.0 to Visual Studio 2010 and that helps greatly to bring the development up to speed. We also will not make the Unicode transition for a few years to come. If Microsoft would not provide the compatibility feature I would build it myself.

As a side note we are a major ISV in a specialized field. If we decide to change OS, an entire Industry would probably change to. (Before Windows we used to also build a specialised OS.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文