ccsimpc -g -mpentium -ansi -fno-builtin -fno-defer-pop -I. -IC:\Tornado2.2\target\h\ -DCPU
=SIMNT -DTOOL_FAMILY=gnu -DTOOL=gnu -c ..\udpClient.c
..\udpClient.c:16: parse error before `udpClient'
make: *** [udpClient.o] Error 0x1
Done.
这是为什么?
源程序如下:
#include "vxWorks.h"
#include "sockLib.h"
#include "inetLib.h"
#include "stdioLib.h"
#include "strLib.h"
#include "hostLib.h"
#include "ioLib.h"
#include "udp.h"
STATUS udpClient (char * serverName)
{struct request myRequest;
struct sockaddr_in serverAddr;
char display;
int sockAddrSize;
int sFd;
int mlen;
if((sFd=socket(AF_INET,SOCK_DGRAM,0))==ERROR)
{
perror ("socket");
return (ERROR);
}
sockAddrSize = sizeof (struct sockaddr_in);
bzero ((char *) &serverAddr,sockAddrSize);
serverAddr.sin_len = (u_char) sockAddrSize;
serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons (SERVER_PORT_NUM);
if(((serverAddr.sin_addr.s_addr = inet_addr (serverName)) == ERROR)&&((serverAddr.sin_addr.s_addr = hostGetByName (serverName))==ERROR))
{
perror ("unknown server name");
close (sFd);
return (ERROR);
}
/* */
printf ("Message to send: \n");
mlen = read (STD_IN,myRequest.message,REQUEST_MSG_SIZE);
myRequest.message[mlen - 1]='\0';
printf("Would you like the server to display your message (Y or N):\n");
read (STD_IN,&display,1);
switch(display)
{
case 'y':
case 'Y':myRequest.display =TRUE;
break;
default : myRequest.display = FALSE;
break;
}
if(sendto (sFd,(caddr_t) &myRequest,sizeof (myRequest),0,(struct sockaddr *) &serverAddr,sockAddrSize)==ERROR)
{
perror ("sendto");
close (sFd);
return (ERROR);
}
close (sFd);
return (OK);
}