Resolution of: is this really an illigal combination?

Jim Klavetter jjk at astro.UMD.EDU
Tue Jan 16 16:00:21 AEST 1990


The original article is below for those of you who care.  Basically,
I had a problem with an "illegal combination" warning when I included
the <strings.h> file as the man page suggested but did not when I
included <string.h>.

The problem seems to be a combination of some confusion in the man
page coupled with the sun os trying to be compatible with Sys V and
BSD (perhaps this isn't restricted to Suns and perhaps it is something
that will be more of a concern as Unix expands).

In any case, the code is ok, but be careful to check your site for the
correct definitions in <string.h> (from Sys V) and <strings.h> (from
BSD).  As George Kaplan correctly explained:

It looks like a problem in the SunOS 4.0.3 man page.  On our Sun 3/180
running 3.5.2 the man page correctly describes which functions are
declared in <string.h> and <strings.h>.  In the corresponding man page
on
our Sparcstation running 4.0.3, though, it looks like someone has
replaced all occurrences of "string.h" with "strings.h", even in the
"NOTES" section that's supposed to explain the difference.  Very
confusing.

Guy Harris explains further:

Ultimately, ANSI C will steamroller over this difference; it chose to
go the S3/S5 way, which means the routines are named "strchr" and
"strrchr" and the proper include file is <string.h>.

Thanks to all who replied.

jjk


(Original article follows:)
  
In article <5947 at umd5.umd.edu> jjk at astro.UMD.EDU writes:
>With the following declarations:
>
>char *nam, *pstring;
>
>I get an warning message with the following line of code:
>
>if(NULL==(pstring=strrchr(nam, '.')) || strcmp(pstring,".imh"))
>
>The warning from my compiler is
>
>"imropen.c", line 17: warning: illegal combination of pointer and integer, op =
>
>Everything works as I expect.  Furthermore, this code is analagous to
>code I found in the book TOPICS IN C PROGRAMMING by Kochan and Wood.
>
>Note that I have isolated the warning to the fragment
>
>pstring=strrchr(f77nam, '.');
>
>and I HAVE included <strings.h> as the manual indicates.  If I include
><string.h>, however (not indicated by the man page), I do not get the
>warning message.  In <string.h> there is 
>
>extern char *strrchr();
>
>not in <strings.h>.  
>
>So the real question is:  is there a bug in <strings.h> or the man
>page or my code or my compiler?
>
>I am on a sun 3/50 running 4.0.3.  E-mail replies since and I will
>post if there is a definitive answer.
>
>jjk at astro.umd.edu



More information about the Comp.lang.c mailing list