为什么Windows和Linux之间的标准库函数名称不同? [英] Why are standard library function names different between Windows and Linux?

查看:547
本文介绍了为什么Windows和Linux之间的标准库函数名称不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Windows库移植到Android(使用GNU标准C ++库选项,libstdc ++ - v3),并且VC和GNU库之间似乎有许多命名差异,例如:

I am porting a Windows library to Android (with the GNU Standard C++ Library option, libstdc++-v3) and there seem to be numerous naming differences between the VC and GNU libraries, e.g.:


  • _stricmp 代替
  • $ b调用 strcasecmp $ b
  • _unlink 称为 unlink

  • _scalb 称为 scalbn

  • _finite 被称为 isfinite

  • _isnan isnan

  • _itoa itoa 似乎存在于GNU C ++

  • atoi 确实存在,但不是 atoi64

  • _stricmp is called strcasecmp instead
  • _unlink is called unlink
  • _scalb is called scalbn
  • _finite is called isfinite
  • _isnan is called isnan
  • _itoa and itoa do not seem to exist in GNU C++
  • atoi does exist, but not atoi64

VC和GNU库的文档意味着它们实现了ISOC ++,例如我可以得到一些警告VC2008不使用ISO C ++名称,如下面的一个:warning C4996:'itoa':不推荐使用该项的POSIX名称,而是使用ISO C ++一致性名称:_itoa。类似地,GNU的手册说GNU标准C ++库v3是一个正在实施的ISO 14882标准C ++库的项目。

The documentation of both VC and GNU libraries implies that they implement "ISO" C++, for example I can get a few warnings out of VC2008 for not using "ISO C++" names, such as this one: "warning C4996: 'itoa': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _itoa." Similarly GNU's manual says "The GNU Standard C++ Library v3 is an ongoing project to implement the ISO 14882 Standard C++ library".

那么如何使用这些不同的库名称?

So how do the libraries end up with these different names? How can I tell which names are more "standard"?

此外,在任何地方都有一个索引的libstdc ++ - v3,也就是一个简单的列表的所有功能在图书馆?我只能找到手册源文档,它似乎不提供函数列表。

Also, is there an index of libstdc++-v3 anywhere, i.e. a simple list of all functions in the library? I can only find a manual and the "source documentation" which does not appear to offer a list of functions.

推荐答案

p>这和C ++标准库没有什么关系。它与C99和POSIX更相关。

This has very little to do with the C++ standard library. It has more to do with C99 and POSIX.


  • strcasecmp 是一个POSIX函数libstdc ++碰巧实现。 msvcrt通常与POSIX保持一定长度。

  • unlink 是类似的 - 是一个POSIX函数。

  • scalbn 是C99标准中函数的名称。 MSVC不支持C99。然而, scalbn 是C ++ 11的一部分,因此我希望最终显示在msvcrt中。

  • isfinite isnan 都是C99。

  • itoa 既不是C99也不是POSIX。

  • strcasecmp is a POSIX function that libstdc++ happens to implement. msvcrt typically stays at arm's length from POSIX.
  • unlink is similar—it's a POSIX function.
  • scalbn is the name of the function in the C99 standard. MSVC doesn't support C99. However, scalbn is part of C++11, so I would expect it to show up in msvcrt eventually.
  • isfinite and isnan are both C99.
  • itoa is neither C99 nor POSIX. It's a strange beast that just shows up in the night.

我还会指出其他几个人指出的:技术上更正确的前缀标准库中的任何实际上是非标准的下划线的函数。这是msvcrt中下划线扩散的原因。

I'll also point out what several others have pointed out: it's technically more correct to prefix any functions in the standard library that are actually non-standard with an underscore. That's the reason for the proliferation of underscores in msvcrt.

这篇关于为什么Windows和Linux之间的标准库函数名称不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆