lewine@cheshirecat.webo.dg.com (Donald Lewine) (06/11/91)
Submitted-by: lewine@cheshirecat.webo.dg.com (Donald Lewine) In article <4369@rwthinf.UUCP>, berg@physik.tu-muenchen.de (Stephen R. van den Berg) writes: |> Could someone knowledgable please tell me if the following include files, |> the mentioned identifiers and the include files they are 'allocated' to are |> all conform the POSIX standard? (I dont't have any POSIX literature, |> so all the data I present here are educated guesses). To solve this problem at less than half the price of the IEEE standard, and get much more information, see below. . . |> #include <unistd.h> ^^^^^^^^^^^^^^^^^^ unistd.h contains the prototypes for the functions you list and should be included in an ANSI C system. |> /* open() read() write() close() dup() pipe() |> fork() getpid() execve() execvp() */ |> #include <stdio.h> /* sscanf() setbuf() fclose() stdin stdout |> stderr fopen() fread() fwrite() fgetc() |> getchar() FILE */ |> #include <stddef.h> /* EOF */ NO. EOF is defined in <stdio.h>. <stddef.h> defines: NULL, offsetof, ptrdiff_t, size_t, wchar_t |> #include <stdlib.h> /* getenv() memmove() malloc() realloc() |> free() strtol() size_t */ memmove() is in <string.h> all others are in <stdlib.h> |> #include <time.h> /* time() ctime() time_t */ |> #include <fcntl.h> /* O_RDONLY O_WRONLY O_APPEND O_SYNC */ O_SYNC is not a POSIX symbol |> #include <pwd.h> /* setpwent() getpwuid() endpwent() */ setpwent() is not in POSIX.1 (admin func) endpwent() is not in POSIX (not needed) |> #include <sys/wait.h> /* wait() */ |> #include <sys/utsname.h> /* uname() utsname */ |> #include <sys/types.h> /* pid_t mode_t struct stat */ struct stat is in <sys/stat.h> |> #include <sys/stat.h> /* stat() S_ISDIR() */ |> #include <signal.h> /* signal() kill() */ |> #include <string.h> /* strcpy() strncpy() strcat() strlen() |> strspn() strcspn() strchr() strcmp() |> strncmp() strpbrk() strstr() */ |> #include <errno.h> /* EINTR EEXIST EMFILE ENFILE */ The header files contain symbols in addition to the ones you list. A complete listing of the POSIX headers is in Appendix A of the POSIX Programmer's Guide available for $34.95 from: O'Reilly and Associates, Inc. 632 Petaluma Ave Sebastopol, CA 95472 (800) 338-6887 uunet!ora!nuts nuts@ora.uu.net In my not so humble opinion, the POSIX Programmer's Guide is required reading for anyone who wants to write programs that work on all POSIX systems. -------------------------------------------------------------------- Donald A. Lewine (508) 870-9008 Voice Data General Corporation (508) 366-0750 FAX 4400 Computer Drive. MS D112A Westboro, MA 01580 U.S.A. uucp: uunet!dg!lewine Internet: lewine@cheshirecat.webo.dg.com Volume-Number: Volume 23, Number 100
fred@mindcraft.com (Fred Zlotnick) (06/13/91)
Submitted-by: fred@mindcrf.uucp (Fred Zlotnick) In article <1991Jun12.035046.16547@uunet.uu.net> lewine@cheshirecat.webo.dg.com (Don Lewine) writes: >In article <4369@rwthinf.UUCP>, berg@physik.tu-muenchen.de >(Stephen R. van den Berg) writes: >|> Could someone knowledgable please tell me if the following include files, >|> the mentioned identifiers and the include files they are 'allocated' to are >|> all conform the POSIX standard? > >To solve this problem at less than half the price of the IEEE >standard, and get much more information, see below. . . [ Many correct comments omitted... ] >|> #include <stdlib.h> /* getenv() memmove() malloc() realloc() >|> free() strtol() size_t */ > memmove() is in <string.h> all others are > in <stdlib.h> memmove() is not supported by POSIX.1. Clause 8.1 of the POSIX.1 standard lists 110 functions from the C standard and states that POSIX.1 with the C Language binding comprises these functions, the extensions to them described in this clause, and the rest of the requirements stipulated in [this standard]. The C standard specifies 22 functions in <string.h>. Only 14 of them are listed in POSIX.1, and memmove() is not one of these. Thus a strictly conforming POSIX.1 application should not use memmove(). I was going to avoid using this newsgroup for advertising, but since Donald has already broken the ice, I might mention that you can also find the contents of all POSIX.1 and ANSI C headers in Appendix D of my book, "The POSIX.1 Standard: a Programmer's Guide", available for $29.95 from Benjamin/Cummings Publishing Company 390 Bridge Parkway Redwood City, 94065 (800) 950-BOOK for information (800) 447-2226 for orders or at better bookstores almost everywhere. My opinion of my book is as unhumble as Don's opinion of his. (And I'm sure that he has written a very fine book.) -- Fred Zlotnick | #include <std.disclaimer> fred@mindcraft.com | #include <brilliant.quote> ...!{decwrl,ames}!mindcrf!fred | Volume-Number: Volume 24, Number 8
gwc@root.co.uk (Geoff Clare) (06/15/91)
Submitted-by: gwc@root.co.uk (Geoff Clare)
berg@physik.tu-muenchen.de (Stephen R. van den Berg) wrote:
] Could someone knowledgable please tell me if the following include files,
] the mentioned identifiers and the include files they are 'allocated' to are
] all conform the POSIX standard? (I dont't have any POSIX literature,
] so all the data I present here are educated guesses).
I emailed my answer to Stephen like a good net.user, but now I see
that an incorrect answer has been posted to the newsgroup, so I feel
obliged to waste more bandwidth by correcting it.
lewine@cheshirecat.webo.dg.com (Donald Lewine) writes:
]|>
] #include <unistd.h>
] ^^^^^^^^^^^^^^^^^^ unistd.h contains the prototypes for the
] functions you list and should be included in
] an ANSI C system.
Except that open() is in <fcntl.h>, not <unistd.h>. Also the comments
regarding prototypes and ANSI C are misleading. The original poster asked
about "POSIX", he didn't specify "POSIX with ANSI C", so I assume he wants
answers which apply equally well to POSIX with either common C or ANSI C.
]|> #include <stddef.h> /* EOF */
] NO. EOF is defined in <stdio.h>.
] <stddef.h> defines:
] NULL, offsetof, ptrdiff_t, size_t, wchar_t
<stddef.h> is not required by POSIX.1.
]|> #include <stdlib.h> /* getenv() memmove() malloc() realloc()
]|> free() strtol() size_t */
] memmove() is in <string.h> all others are
] in <stdlib.h>
memmove() and strtol() are not required by POSIX.1.
]|> #include <signal.h> /* signal() kill() */
signal() is not required by POSIX.1.
]A complete listing of the POSIX headers is in Appendix A of the
]POSIX Programmer's Guide available for $34.95 from:
(address deleted)
]In my not so humble opinion, the POSIX Programmer's Guide is
]required reading for anyone who wants to write programs that
]work on all POSIX systems.
I hope it wasn't the source of the errors above.
--
Geoff Clare <gwc@root.co.uk> (Dumb American mailers: ...!uunet!root.co.uk!gwc)
UniSoft Limited, London, England. Tel: +44 71 729 3773 Fax: +44 71 729 3273
Volume-Number: Volume 24, Number 7