LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-02-2006, 08:36 AM   #1
rzarector
LQ Newbie
 
Registered: Oct 2006
Posts: 4

Rep: Reputation: 0
Unhappy differ in signedness error


Good Morning,

I am trying to compile some c code (which compiled on Fedora Core 4 and CentOS) but now wont compile on Ubuntu.... This is the following error I am getting when I try to compile and I have alos posted the source code. Any Ideas?

lyoussef@lyoussef:~/Desktop/working code$ gcc chats.c
chats.c: In function ‘main’:
chats.c:55: warning: pointer targets in passing argument 3 of ‘accept’ differ in signedness
/tmp/ccJ5AgRk.o: In function `main':chats.c.text+0x8f): undefined reference to `passivesock'
collect2: ld returned 1 exit status

*** SOURCE ***
Code:
/*  Wait for someone to chat with you */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include "sock.h"

#define QLEN 0
#define BUFSIZE 4096

extern int  errno;
//extern char *sys_errlist[];

int main( int argc, char *argv[] )
{
	char                *service;
	int                 rport = 0;
	struct sockaddr_in  fsin;
	int                 alen;
	int		sd, ssock;
	int		n;
	char		buffer[BUFSIZE];
   
	switch (argc)
	{
		case    1:
			rport = 1;
			break;
		case    2:
			service = argv[1];
			break;
		default:
			//errexit( "usage: chatd [port]\n" );
			printf("usuage: chatd [port]\n");
			exit (-1);
	}

	/*  Create the server socket */

	sd = PASSIVE_TCP( service, QLEN, &rport );
	if (rport)
	{
		/*  Tell the user the selected port  */
		printf( "chatd: port %d\n", rport );
		fflush( stdout );
	}


	/*  Wait for someone to show up and then establish a connection with them */
	alen = sizeof(fsin);
	
	ssock = accept(sd, (struct sockaddr *)&fsin, &alen );
	if (ssock < 0)
		// errexit("accept: %s\n", sys_errlist[errno]);
		exit (-1);

	/* Take turns with your partner */
	/* Enter "Q" to quit */

	for (;;)
	{
		if ( (n = read( ssock, buffer, BUFSIZE )) > 0 )
		{
		/*	printf( "Got a buffer." ); */
			;
		}

		else
		{
			close( ssock );
			break;
		}

	}

	close( sd );
		
}

Last edited by rzarector; 10-02-2006 at 09:13 AM.
 
Old 10-02-2006, 08:55 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Hi

Maybe change
Code:
int alen;
to
Code:
size_t alen;
 
Old 10-02-2006, 09:01 AM   #3
rzarector
LQ Newbie
 
Registered: Oct 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Guttorm
Hi

Maybe change
Code:
int alen;
to
Code:
size_t alen;
Thanks! that worked but now its not finding the sock.h header file with the definition for passivesocket
Code:
/tmp/cce1NHCC.o: In function `main':chats.c:(.text+0x8f): undefined reference to `passivesock'
and i am getting
Code:
lyoussef@lyoussef:~/Desktop/working code$ make
    Compiling chats.c . . .
    Compiling connectsock.c . . .
connectsock.c: In function ‘connectsock’:
connectsock.c:37: warning: incompatible implicit declaration of built-in function ‘bzero’
connectsock.c:49: warning: incompatible implicit declaration of built-in function ‘bcopy’
    Compiling passivesock.c . . .
passivesock.c: In function ‘passivesock’:
passivesock.c:37: warning: incompatible implicit declaration of built-in function ‘bzero’

Last edited by rzarector; 10-02-2006 at 09:14 AM.
 
Old 10-02-2006, 09:06 AM   #4
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora and others
Posts: 757

Rep: Reputation: 145Reputation: 145
BTW, your code will be easier to read in posts if you wrap your code in a [code] block, or highlight it and then click the the # icon.

Also, you can click Disable smilies in text under Additional Options below the editor to avoid those annoying smiley faces that replace your text. For example: :( :)
 
Old 10-02-2006, 09:13 AM   #5
rzarector
LQ Newbie
 
Registered: Oct 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by KenJackson
BTW, your code will be easier to read in posts if you wrap your code in a [code] block, or highlight it and then click the the # icon.

Also, you can click Disable smilies in text under Additional Options below the editor to avoid those annoying smiley faces that replace your text. For example:
point noted and updated thanks
 
Old 10-02-2006, 09:53 AM   #6
rzarector
LQ Newbie
 
Registered: Oct 2006
Posts: 4

Original Poster
Rep: Reputation: 0
I figured out the problem. Thanks all for your help!
 
Old 10-02-2006, 01:05 PM   #7
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
Quote:
Originally Posted by KenJackson
Also, you can click Disable smilies in text under Additional Options below the editor to avoid those annoying smiley faces that replace your text. For example: :( :)
wow. i have never saw that hiding down there. thanks. :)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
About pointer signedness warnings isuck@linux Linux - Software 2 08-26-2006 07:18 PM
if Post_data parameter's value differ? punisher_by Programming 1 02-06-2006 03:48 PM
differ between proxysever and NAT vito_huang Linux - Networking 1 12-26-2004 01:56 AM
they do differ? [kernel in every distro] junkie101 Linux - Software 1 10-27-2004 08:16 AM
How does Fedora differ from RH9? Big Al Fedora 10 11-12-2003 10:13 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration