难道他们的&QUOT部分C

难道他们的&QUOT部分C

本文介绍了你可以在C离不开"性病QUOT;包括?难道他们的&QUOT部分C,QUOT;或者只是库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我道歉,如果这是一个主观的或反复的问题。这有点尴尬的搜索,所以我不知道要包括哪些条款。

I apologize if this is a subjective or repeated question. It's sort of awkward to search for, so I wasn't sure what terms to include.

我想知道什么是基本的基础工具/功能在C时不包括标准库,例如 STDIO STDLIB

What I'd like to know is what the basic foundation tools/functions are in C when you don't include standard libraries like stdio and stdlib.

我能做的,如果没有的printf() fopen()函数,等?

What could I do if there's no printf(), fopen(), etc?

此外,那些图书馆技术上C语言的一部分,或者他们只是非常有用和有效的必备库?

Also, are those libraries technically part of the "C" language, or are they just very useful and effectively essential libraries?

推荐答案

C标准有这样一段话(5.1.2.3/5):

The C standard has this to say (5.1.2.3/5):

这是一个符合要求的最低要求
  实现是:

- 在序列点,挥发物
  是在previous感稳定
  访问齐全,随后
  访问还没有发生。

— At sequence points, volatile objects are stable in the sense that previous accesses are complete and subsequent accesses have not yet occurred.

- 在程序终止,所有的数据
  写入文件应是相同的
  到的结果的该执行
  根据抽象程序
  语义就会产生。

— At program termination, all data written into files shall be identical to the result that execution of the program according to the abstract semantics would have produced.

- 的输入和输出的动态
  交互设备应采取的地方
  如在规定
  7.19.3。

— The input and output dynamics of interactive devices shall take place as specified in 7.19.3.

因此​​,如果没有标准库函数,一个程序保证具有唯一的行为,涉及挥发性对象的值,因为你不能使用任何的担保文件访问或交互设备。 纯C只能通过标准库函数提供了互动。

So, without the standard library functions, the only behavior that a program is guaranteed to have, relates to the values of volatile objects, because you can't use any of the guaranteed file access or "interactive devices". "Pure C" only provides interaction via standard library functions.

纯C是不是故事的全部,不过,因为你的硬件可能有读取或写入(无论是SATA或PCI总线,原始视频内存,串行端口,有事去的时候里面做某些事某些地址嘟嘟声或闪烁的LED)。因此,了解您的硬件的,你可以用C一大堆文字不使用标准库函数的东西。可能,你可以实现C标准库,尽管这可能需要访问特殊的CPU指令以及特殊内存地址。

Pure C isn't the whole story, though, since your hardware could have certain addresses which do certain things when read or written (whether that be a SATA or PCI bus, raw video memory, a serial port, something to go beep, or a flashing LED). So, knowing something about your hardware, you can do a whole lot writing in C without using standard library functions. Potentially, you could implement the C standard library, although this might require access to special CPU instructions as well as special memory addresses.

但在纯C,没有扩展名,并取消了标准库函数,你基本上不会比读取命令行参数,做了一些工作,并从<$ C返回一个状态code做的任何其他$ C>主。这不是在,它仍然图灵完整受到资源限制被​​嗅探,虽然你的唯一资源是自动和静态变量,没有堆分配。这不是一个很丰富的编程环境。

But in pure C, with no extensions, and the standard library functions removed, you basically can't do anything other than read the command line arguments, do some work, and return a status code from main. That's not to be sniffed at, it's still Turing complete subject to resource limits, although your only resource is automatic and static variables, no heap allocation. It's not a very rich programming environment.

标准库是C语言规​​范的一部分,但在任何语言也确实往往是语本身之间画一条线,和库。这是一个概念上的差异,但最终原则上不一个非常重要的,因为标准说,他们走到了一起。任何人做一些非标可以很容易地删除语言特征库。无论哪种方式,结果是不是C的符合标准的实现。

The standard libraries are part of the C language specification, but in any language there does tend to be a line drawn between the language "as such", and the libraries. It's a conceptual difference, but ultimately not a very important one in principle, because the standard says they come together. Anyone doing something non-standard could just as easily remove language features as libraries. Either way, the result is not a conforming implementation of C.

请注意,一个独立的实施的C只有实现标准的一个子集,包括不包括任何的I / O,让你的位置是我上面描述依靠特定硬件的扩展来获得的,什么有趣的事做。如果你想绘制基于标准的核心语言和库之间的区别,那么这可能是拿捏的好地方。

Note that a "freestanding" implementation of C only has to implement a subset of standard includes not including any of the I/O, so you're in the position I described above, of relying on hardware-specific extensions to get anything interesting done. If you want to draw a distinction between the "core language" and "the libraries" based on the standard, then that might be a good place to draw the line.

这篇关于你可以在C离不开&QUOT;性病QUOT;包括?难道他们的&QUOT部分C,QUOT;或者只是库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 02:07