HP OpenVMS Systems

ask the wizard
Content starts here

C compilation error? (incompatible pointers)

» close window

The Question is:

 
I am having problems compiling a C program which uses sockets.  I've used a
TCP/IP server example from a DEC C RTL reference manual as a pattern (see
http://www.opus1.com/vmsdoc/progtool/decc57a/5763p057.htm).  We're using DEC
C V5.0-003, and OpenVMS 6.2
on an Alpha.  When I compile, I get this message:
 
  rval = bind(sock, &sock_name, namelength);
.........^
In this statement, the referenced type of the pointer value "&sock_name" is
"struct sockaddr_in",
which is not compatible with "struct sockaddr".
at line number 49 in file SYS$SYSDEVICE:[USERS.TOM_N]TCPSERVER.C;38
 
The documentation states that to get the bind variant __bsd44_bind, define
_sockaddr_len when compiling.  This did not change the outcome.  What do I
need to do?
 
Thank you for any helpful hints you may give.
 
 


The Answer is :

 
  You are passing "struct sockaddr_in", when "struct sockaddr" is
  expected.  You will want to redefine the sock_name variable as
  type sockaddr, or you will want to use a void cast or similar.
  In other words, there is apparently an error in the example code.
 
  The Wizard would also recommend upgrading to DEC C V5.7 or later.
 

answer written or last revised on ( 8-FEB-1999 )

» close window