【问题标题】:Why is the isnumber() function present in certain distros of Unix but not in others? [closed]为什么在某些 Unix 发行版中存在 isnumber() 函数,而在其他发行版中不存在? [关闭]
【发布时间】:2012-11-09 04:43:09
【问题描述】:

我正在编写一个小型 C 程序,在其中调用 isnumber() 函数。

#include <ctype.h>

char c
if(isnumber(c)) 
    { foo }

这在我的 Mac (OS X 10.8) 上编译没有问题。但是,当我将它上传到 CentOS 6.x 服务器时,它不会编译。此外,the OS X man page for isdigit() 描述了isnumber(),但 CentOS 的man 页面没有。就好像它根本不存在于 Linux 机器上一样。 the OS X man page for isdigit()a general Unix man page for isdigit() 都将 isnumber() 列为 C 标准库 libc, -lc 的一部分。当我在 Linux 上将 -lc 添加到编译标志时,它仍然无法编译。

为什么这个函数包含在 Unix 的某些形式中而不包含在其他形式中?

【问题讨论】:

    标签: c linux macos unix compiler-construction


    【解决方案1】:

    isnumber() 是一个BSDism,如链接手册页的“历史”部分所示:

    isnumber() 函数出现在 4.4BSD 中。

    OS X 展示了它的传统......

    还有一个标准部分谈论isdigit,但对isnumber保持沉默。

    无论如何,Linux、BSD 或 OS X 手册页不应被视为 C 语言甚至 POSIX 标准的权威。对于 C,请阅读 C 标准规范(很容易找到),对于 POSIX,您可以阅读 OpenGroup web site

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-15
      • 1970-01-01
      • 2021-07-17
      • 1970-01-01
      • 1970-01-01
      • 2011-10-10
      • 2018-07-09
      • 2020-10-12
      相关资源
      最近更新 更多