[comp.lang.c] 'incompatble types error'- help needed

hurf@batcomputer.tn.cornell.edu (Hurf Sheldon) (06/25/87)

	Under Ultrix(DEC) and UTX(Gould) I get a compiler (and lint) error 
about unacceptable types that does no occur under 4.3bsd - I have looked at
the pertinent include files on 4.3 and Ultrix and they are identical as
far as my problem is concerned.

  the problem (from tn3270's telnet.c)
		sin.sin_addr.s_addr = inet_addr(argv[1])
causes the error " operands of = have incompatible types"
where argv is declared char *argv[], 'sin.sin_addr.s_addr' is
u_long (from include/netinet/in.h ) and inet_addr() is declared
'external unsigned long inet_addr();' in telnet.c

Is there a way to get this past the compiler - I have tried a couple of
(probably simplistic) redefines and they have made thing worse.
thanks,
hurf
-- 
     Hurf Sheldon			 Network: hurf@ionvax.tn.cornell.edu
     Lab of Plasma Studies		  Bitnet: hurf@CRNLION
     369 Upson Hall, Cornell University, Ithaca, N.Y. 14853  ph:607 255 7267
     I sold my Elan, got a job in science; Now, no one takes me seriously.

toma@killer.UUCP (Tom Armistead) (07/01/87)

In article <1524@batcomputer.tn.cornell.edu>, hurf@batcomputer.tn.cornell.edu (Hurf Sheldon) writes:
>  /* text removed . . . */
> 
>   the problem (from tn3270's telnet.c)
> 		sin.sin_addr.s_addr = inet_addr(argv[1])
> causes the error " operands of = have incompatible types"
> where argv is declared char *argv[], 'sin.sin_addr.s_addr' is
> u_long (from include/netinet/in.h ) and inet_addr() is declared
> 'external unsigned long inet_addr();' in telnet.c
> 
> Is there a way to get this past the compiler - I have tried a couple of
> (probably simplistic) redefines and they have made thing worse.

I don't what the type 'u_long' is, but if is a true type, like 'char' or
'int', ect..., then a type cast oper. should do it for you, like this:

        sin.sin_addr.s_addr = (u_long)inet_addr(argv[1]);
                              ^^^^^^^^
                                 |__this is the 'Type Cast'

Tom
UUCP:           ihnp4\
                      \killer!toma
  infoswx!convex!dj3b1/
Tom Armistead