3

Browsing through the v7 UNIX Sources I noticed there is no "stdlib" directory - further more using a v7 UNIX Emulator, there is no such file as <stdlib.h>. However functions like exit() and malloc(), realloc(), free() .etc. all exist in v7 UNIX. Also by c89 (ANSI) there was definitely a <stdlib.h> because it is present in K&R ANSI Edition. After hours of Google-ing I turn to SE :)

So my question is: When was <stdlib.h> first used officially in c? What is it's history (i.e. was it used by BSD, and then later included into c89?

Thank You.

3

The c89 standard would be the place to look; its rationale was published separately (and is not part of the standard). stdlib.h was a creation of the committee working on the standard rather than reflecting existing practice. The X3J11 rationale says:

The header <stdlib.h> was invented by the Committee to hold an assortment of functions that were otherwise homeless.

Old programs have ifdef's for the inclusion of stdlib.h, versus other places such as memory.h for memcpy, malloc and the like.

This does not say that until the standard was published, there was no stdlib.h. For example, I have a note in one of my header files stating that VMS 5.3 (released June 1989) had stdlib.h:

#if defined(vms)        /* VAX/VMS 5.3 */
#define HAVE_STDLIB_H 1
#define HAVE_STDARG_H 1
#undef  HAVE_UNISTD_H
#define HAVE_OLD_TOKEN_SPLICE 1
#define HAVE_OLD_TOKEN_QUOTE  1
#endif

Rather, the companies which participated in the standard development incorporated these features as the standard progressed, so that when it was published, it reflected existing practice.

In the same header (and its history), I can see that SVr3 did not have stdlib.h (referring to Apollo's svr5.5 environment), but that it appeared "later" (probably with SVr4, which was being developed around the same time as the c89 standard).

Regarding the point about BSDs, I can see that it appeared in 4.3reno in 1990 (too late to be relevant). Likewise, it is easy to find comments that say SunOS 4 is pre-ANSI (although I recall an ANSI compiler added as an option fairly late in the process). So let's disregard BSDs from a role as influences on this header, and leave it as the companies which were involved in the standard development.

For what it's worth, the rationale mentions trademarks of AT&T and Digital Equipment Corporation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.