geoff@cs.warwick.ac.uk (Geoff Rimmer) (05/13/89)
In the preface to K&R 2, it states that "The [ANSI C] standard ... specifies a standard library, with an extensive set of functions for performing input and output, memory management, string manipulation, and similar tasks." In view of this, is the C standard library going to become part of every ANSI C compiler? (I am thinking in particular of gcc). That is to say, will every C compiler that conforms to the standard, contain all the 15 standard include files (K&R 2, Appendix B) and the C standard library of functions? If so, does this mean that there will be two "include" directories? One for the standard include files, and one for the implementation-dependent include files? And will we need two separate libraries? (For example, as far as I know, ANSI C is not required to have the function "opendir". However, this appears in many C libraries at present). Thanks in advance. Geoff - "C retains the basic philosophy that programmers know what they are doing" - K&R 2 /---------------------------------------------------------------\ | GEOFF RIMMER - Friend of COCA COLA CLASSIC | | email : geoff@uk.ac.warwick.cs | | address : Computer Science Dept, Warwick University, | | Coventry, England. | | PHONE : +44 203 692320 (secretary will take message) | | FAX : +44 865 726753 | \---------------------------------------------------------------/
gwyn@smoke.BRL.MIL (Doug Gwyn) (05/16/89)
In article <1875@ubu.warwick.UUCP> geoff@cs.warwick.ac.uk (Geoff Rimmer) writes: >In view of this, is the C standard library going to become part of >every ANSI C compiler? (I am thinking in particular of gcc). Yes, conformance to the ANSI C standard includes provision of the relevant standard headers and library functions. Note that there are two kinds of conforming implementations, for "hosted" environments (e.g. user applications running under control of an operating system) and "freestanding" environments (e.g. dedicated applications, OS kernels, etc.) The "freestanding" implementation is required to supply only a minimal number of standard headers and library functions. >That is to say, will every C compiler that conforms to the standard, >contain all the 15 standard include files (K&R 2, Appendix B) and the >C standard library of functions? Every conforming hosted implementation must. >If so, does this mean that there will be two "include" directories? >One for the standard include files, and one for the implementation- >dependent include files? And will we need two separate libraries? >(For example, as far as I know, ANSI C is not required to have the >function "opendir". However, this appears in many C libraries at present). Conforming implementations may provide any number of extensions; they're not limited to just the standard headers and library. However, their use of the standard headers and library must obey the requirements of the Standard, which boils down to not usurping any names not specified in the Standard (other than ones starting with underscore etc.). Thus, <dirent.h>, opendir(), etc. may be provided by the implementation and they are allowed to do anything at all; however, no Standard library function implementation is allowed to invoke opendir() since that name is reserved for possible application use. Extra functions (not mentioned in the Standard) can invoke opendir(), standard library functions, etc. Some vendors may find it desirable for backwards-compatibility reasons to provide two sets of headers, etc., but it's not technically necessary. For example, an implementation can (with a bit of fancy footwork) manage to be simultaneously ANSI X3.159 (Std C) and IEEE 1003.1 (POSIX) compliant. The intent is that an application compiled in a standard-conforming environment knows for sure what names it can use for its own purposes. (I.e., any name not flagged by the Standard as "reserved".)