[comp.lang.c] <string.h> vs <strings.h>

chris@mimsy.UUCP (Chris Torek) (10/15/88)

In article <8649@smoke.ARPA> gwyn@smoke.ARPA (Doug Gwyn) writes:
><strings.h> doesn't declare strtok, so it is assumed to return int
>which is not compatible with the char * being assigned into.
><strings.h> was invented by Berkeley without regard for existing
>practice.

`Existing practise' being, at the time, either PWB or SysIII, neither
of which could be considered somehow more valid than BSD.  I know not
who was truly first, but one could just as easily say `<string.h> was
invented by AT&T USG without regard for existing practise.'  (Actually,
the places to look are V7 and 32/V.)

><string.h> is the official standard header for the str* functions,
>and it does declare strtok.

... and in the future, expect the 4BSD <strings.h> to simply be a
link to <string.h>.  In the meantime, just use the latter; it does
exist in 4.3BSD and is *now* clearly the best choice.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

dhesi@bsu-cs.UUCP (Rahul Dhesi) (10/16/88)

In article <14002@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
>... and in the future, expect the 4BSD <strings.h> to simply be a
>link to <string.h>.  In the meantime, just use the latter...

Writing portable code would be less frustrating if we had this
preprocessor conditional:

#if exists(<strings.h>)
#include <strings.h>
#else
#include <string.h>
#endif
-- 
Rahul Dhesi         UUCP:  <backbones>!{iuvax,pur-ee}!bsu-cs!dhesi

les@chinet.chi.il.us (Leslie Mikesell) (10/18/88)

In article <4354@bsu-cs.UUCP> dhesi@bsu-cs.UUCP (Rahul Dhesi) writes:
>
>Writing portable code would be less frustrating if we had this
>preprocessor conditional:
>
>#if exists(<strings.h>)
>#include <strings.h>
>#else
>#include <string.h>
>#endif

Likewise for the functions available from the standard library.  I know
ANSI is supposed to help with this but what about all the non-standard
extensions?  Won't you want to use them if possible?  Things like
Larry Wall's Configure script work but require a unix environment to
execute (extracting names from the library, etc.).  Adding a conditional
like:
#if libfunction bcopy
is probably too much to ask, but how about a standard header file that
could be included that would have a #define for each non-standard item?

Les Mikesell