C++ Stdlib IO 实现细节

发布于 2024-11-09 14:07:50 字数 212 浏览 3 评论 0原文

  1. 是否可以保证 C++ std IO 将在所有桌面和移动操作系统上移植(我对 iOS 和 Android 感兴趣)?
  2. std IO 的实现在不同平台上是不同的还是相当统一的?如果不同,那么是否是由于平台的 SDK 导致的(换句话说 - SDK 是否提供了这些不同的实现)?
  3. 谁提供这些实施?作者是谁?有人更新它们吗?
  4. 文档在哪里?
  1. Are there any guarantees that C++ std IO will be portable across all Desktop and Mobile OS (I'm interested in iOS and Android)?
  2. Is implementation of std IO different across the platforms or it is rather uniform? If it is different, then does it happen due to SDK of the platform (in other words - do SDK's provide those different implementations)?
  3. Who provide those implementation? Who is the author? Does anybody update them?
  4. Where is documentation?

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

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

发布评论

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

评论(4

沐歌 2024-11-16 14:07:50

是否有任何保证 C++ std
IO 将在所有桌面上移植
和移动操作系统(我对 iOS 感兴趣
和 Android)?

不,不能保证这些平台能够正确实现所有标准库。

std IO 的实现是否不同
跨平台或者更确切地说
制服?如果不同,那么
这是由于平台的SDK而发生的
(换句话说 - SDK 是否提供
那些不同的实现)?

这是不同的。不同平台上的 I/O 有很大不同。

谁提供这些实现? WHO
作者是?有人更新吗
他们?文档在哪里?

编译器实现者或平台所有者提供它们。 C++ 标准描述了库必须执行的操作。

Are there any guarantees that C++ std
IO will be portable across all Desktop
and Mobile OS (I'm interested in iOS
and Android)?

No, there are no guarantees that these platforms will implement, correctly at all the standard library.

Is implementation of std IO different
across the platforms or it is rather
uniform? If it is different, then does
it happen due to SDK of the platform
(in other words - do SDK's provide
those different implementations)?

It's different. I/O is very different on different platforms.

Who provide those implementation? Who
is the author? Does anybody update
them? Where is documentation?

Either the compiler implementor or the platform owner provides them. The C++ Standard describes what the library must do.

拥抱没勇气 2024-11-16 14:07:50

我认为您没有看到标准库的力量。它们旨在提供一组通用的功能,可在任何符合标准的编译器上使用。例如,如果我编写以下代码:

#include <iostream>

int main(int a, char** s)
{
  std::cout << "Hello World" << std::endl;
  return 0;
}

这将由任何符合标准的编译器进行编译。您已经被挂断了,好吧,std::cout 的工作方式在每个平台上都是不同的 - 是的,当然是这样。但这就是它的美妙之处——为什么你必须关心呢?在 Windows 上,如果您使用 MS Visual C++ 进行编译,该编译器将具有正确的实现(标准不关心)来支持上述写入标准输出的标准方式。类似地,在 Linux 上,GCC 将具有正确的代码来写入任何实现,而在 Solaris 上,CC 也会执行相同的操作。

您不必担心或坦率地关心。针对您的平台的处理由您用于该平台的编译器提供。您有一个漂亮干净的高级界面可供使用。

你关心Java VM如何处理各个平台的细节吗?你不知道,这不是你关心的,你知道当你执行 System.out.println() 时,它会被适当地写入屏幕(或该虚拟机的任何内容)。那么你为什么对这个耿耿于怀呢?

您要了解的是,您在特定平台上使用的编译器是否将提供标准库中的所有功能(即它是否完全符合标准),如果不是,则缺少什么以及如何解决它。其余的坦率地说无关紧要!

至于如果你不喜欢它,我们会花钱买像 Roguewave 这样的东西——坦率地说,它是在浪费钱,但这是你的钱……

I think you are failing to see the power of the standard libraries. They are designed to provide a common set of functionality that is available across any standards compliant compiler. For example, if I write the following code:

#include <iostream>

int main(int a, char** s)
{
  std::cout << "Hello World" << std::endl;
  return 0;
}

This will be compiled by any standards compliant compiler. You're getting hung up on, well the way std::cout works is different on each platform - yes of course it is. But this is the beauty of it - why do you have to care? On windows, if you compile this with MS Visual C++, that compiler will have the correct implementation (which the standard doesn't care about) to support the above standard way of writing to standard out. Similarly, on Linux GCC will have the correct code to write to whatever implementation, and on Solaris, CC will do the same.

You don't have to worry or frankly care. The handling for your platform is provided by the compiler that you are using for that platform. You have a nice clean high-level interface to work with.

Do you care how the Java VM handles the details of each platform? You don't, it's not your concern, you know when you do System.out.println() it will be written to the screen (or whatever for that VM) appropriately. SO why are you getting hung up on this?

The thing you have understand is whether the compiler that you are using on the specific platform will provide all the functionality in the standard library (i.e. is it fully standards compliant or not) and if not, what's missing and how to work around it. The rest is frankly irrelevant!

As for if you don't like it, well pay for something like Roguewave - which frankly is pissing money away, but it's your money to piss away...

未蓝澄海的烟 2024-11-16 14:07:50

标准库就是标准。它是由标准定义的。每个符合标准的编译器都必须提供它。因此,保证它可以跨符合标准的实现进行移植(是否有适合您的目标平台的实现是一个完全不同的问题)。它与平台 SDK 无关(是否使用 SDK 实现并不重要——可观察的行为必须相同)。

Standard library is exactly that — standard. It's defined by standard. Every standard-compliant compiler must provide it. So the guarantee is that it will be portable across standard-compliant implementations (whether there's one for your target platform is a whole different question altogether). It has nothing to do with platform SDKs (whether it's implemented using one doesn't matter — the observable behaviour must be the same).

又爬满兰若 2024-11-16 14:07:50

标准(因此称为 std)的理念是,无论您使用什么平台,它都受到尊重和统一。
一些开发人员提供的设备支持全部或部分 std 库,这实际上取决于他们如何实现。

这是特定于平台的,并且可能在每个平台的 SDK 文档中提供,最有可能通过 SDK 或在供应商的网站上提供。

The idea of a standard (hence the std) is that it is respected and uniform no matter what platform you are on.
Some developers ship devices with support for all or some of the std library, it's really just up to them how it is implemented.

This is platform specific and probably available in each platform's SDK documentation, available most probably with the SDK or on the vendor's website.

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