Sponsored Content
Top Forums Programming gcc 4.3.2 accept sys call warrning incompatible pointer type Post 302308656 by personificator on Monday 20th of April 2009 01:32:59 AM
Old 04-20-2009
gcc 4.3.2 accept sys call warrning incompatible pointer type

Hi all, this warning is driving me nuts. I use -pedantic with -Wall and -Werror so this needs to be fixed.
BUILD: GNU-Linux-x86

Any ideas?

struct sockaddr_in server_addr;
int addr_len = sizeof (server_addr);

fd = accept(link->socket_fd,
(struct sockaddr_in *) &server_addr,
(socklen_t *) &addr_len));

warning: passing argument 2 of ‘accept' from incompatible pointer type

Thanks for you comments.
 

10 More Discussions You Might Find Interesting

1. Programming

adv reqd on SIGCHLD on accept call

Hi, I have small problem. In my (concurrent)server programm, I am handling accept problem from client like this. sample of server code. /*******************/ end = 0; while (! end ) { sockfd = accept(...) if(sockfd == -1) { if (errno == EINTR) /* this is bcoz... (5 Replies)
Discussion started by: stevenjagan
5 Replies

2. Programming

Accesing structure member:Error:dereferencing pointer to incomplete type

$ gcc -Wall -Werror struct.c struct.c: In function `main': struct.c:18: error: dereferencing pointer to incomplete type $ cat struct.c #include <stdio.h> #include <stdlib.h> #include <string.h> /*Declaration of structure*/ struct human { char *first; char gender; int age; } man,... (3 Replies)
Discussion started by: amit4g
3 Replies

3. Programming

enable 64bit long type for gcc

hey, I believe I once saw a post in this forum, about enable an GCC option to enable long types. I simply cannot find it any more. Can anybody give me a hint? I am on 32bit Ubuntu, and I would like my int be really long. Also I need malloc() take long int argument too. I found it is necessary to... (6 Replies)
Discussion started by: patiobarbecue
6 Replies

4. UNIX for Dummies Questions & Answers

Why do I need to call make if I call gcc ?

Why do I need to call make if I call gcc ? I thought gcc already compiles the sources. thanks (1 Reply)
Discussion started by: aneuryzma
1 Replies

5. Programming

Dereferencing pointer to incomplete type

// Hello all, I am having this error "Dereferencing pointer to incomplete type " on these 2 lines: xpoint = my_point->x; ypoint = my_point->y; I am having no clue y this is happening. Any help would be greately appreciated!!!! #include<stdio.h> #include<string.h>... (2 Replies)
Discussion started by: mind@work
2 Replies

6. Programming

GCC - Incompatible Pointer Types

Hi guys, here is my code written in C and the compiler error message. int i; int (*a); for (i = 1;i <= 9;i++) a = (int *)malloc(sizeof(int) * 10);here is the error: incompatible types when assigning to type ‘int’ from type ‘int *’I want to make a two dimensional array. I... (2 Replies)
Discussion started by: majid.merkava
2 Replies

7. Programming

Compilation Error: dereferencing pointer to incomplete type

I am getting a dereferencing pointer to incomplete type error when i compile the following code on lines highlighted in red. Can anyone help me in identifying what is wrong in the code? #include<stdio.h> #include<stdlib.h> typedef struct{ int info; struct node* link ; } node; void... (3 Replies)
Discussion started by: sreeharshasn
3 Replies

8. Red Hat

Incompatible Level of gcc?

I'm compiling an application someone gave me. It uses XLC on a Power7, running Red Hat (4? 5?). It compiles and links, but I get the following message for every .o and .exe... xlc_r: 1501-274 (W) An incompatible level of gcc has been specified. I've tried googling on this error, and I'll I... (2 Replies)
Discussion started by: Harper21
2 Replies

9. Programming

Warning: pointer type mismatch

Hi all, I'm new programming in C, so I had the next message in my code: Dual.c:88:20: warning: pointer type mismatch in conditional expression : &clientSa.sin6.sin6.sin6_addr, Any help would be great #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include... (1 Reply)
Discussion started by: godna
1 Replies

10. Programming

Incompatible data type fpos_t in C

This is from a program I wrote over in 1998 that I am trying to compile on a linux machine: void write_line (FILE *fp, int rec_no, line_rec *arec) { fpos_t woffset; woffset = (rec_no - 1) * sizeof(line_rec); fsetpos(fp,&woffset); fwrite(arec,sizeof(line_rec),1,fp); }On the line... (2 Replies)
Discussion started by: wbport
2 Replies
BIND(2) 						     Linux Programmer's Manual							   BIND(2)

NAME
bind - bind a name to a socket SYNOPSIS
#include <sys/types.h> /* See NOTES */ #include <sys/socket.h> int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); DESCRIPTION
When a socket is created with socket(2), it exists in a name space (address family) but has no address assigned to it. bind() assigns the address specified by addr to the socket referred to by the file descriptor sockfd. addrlen specifies the size, in bytes, of the address structure pointed to by addr. Traditionally, this operation is called "assigning a name to a socket". It is normally necessary to assign a local address using bind() before a SOCK_STREAM socket may receive connections (see accept(2)). The rules used in name binding vary between address families. Consult the manual entries in Section 7 for detailed information. For AF_INET see ip(7), for AF_INET6 see ipv6(7), for AF_UNIX see unix(7), for AF_APPLETALK see ddp(7), for AF_PACKET see packet(7), for AF_X25 see x25(7) and for AF_NETLINK see netlink(7). The actual structure passed for the addr argument will depend on the address family. The sockaddr structure is defined as something like: struct sockaddr { sa_family_t sa_family; char sa_data[14]; } The only purpose of this structure is to cast the structure pointer passed in addr in order to avoid compiler warnings. See EXAMPLE below. RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately. ERRORS
EACCES The address is protected, and the user is not the superuser. EADDRINUSE The given address is already in use. EBADF sockfd is not a valid descriptor. EINVAL The socket is already bound to an address. ENOTSOCK sockfd is a descriptor for a file, not a socket. The following errors are specific to UNIX domain (AF_UNIX) sockets: EACCES Search permission is denied on a component of the path prefix. (See also path_resolution(7).) EADDRNOTAVAIL A nonexistent interface was requested or the requested address was not local. EFAULT addr points outside the user's accessible address space. EINVAL The addrlen is wrong, or the socket was not in the AF_UNIX family. ELOOP Too many symbolic links were encountered in resolving addr. ENAMETOOLONG addr is too long. ENOENT The file does not exist. ENOMEM Insufficient kernel memory was available. ENOTDIR A component of the path prefix is not a directory. EROFS The socket inode would reside on a read-only file system. CONFORMING TO
SVr4, 4.4BSD, POSIX.1-2001 (bind() first appeared in 4.2BSD). NOTES
POSIX.1-2001 does not require the inclusion of <sys/types.h>, and this header file is not required on Linux. However, some historical (BSD) implementations required this header file, and portable applications are probably wise to include it. The third argument of bind() is in reality an int (and this is what 4.x BSD and libc4 and libc5 have). Some POSIX confusion resulted in the present socklen_t, also used by glibc. See also accept(2). BUGS
The transparent proxy options are not described. EXAMPLE
An example of the use of bind() with Internet domain sockets can be found in getaddrinfo(3). The following example shows how to bind a stream socket in the UNIX (AF_UNIX) domain, and accept connections: #include <sys/socket.h> #include <sys/un.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #define MY_SOCK_PATH "/somepath" #define LISTEN_BACKLOG 50 #define handle_error(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0) int main(int argc, char *argv[]) { int sfd, cfd; struct sockaddr_un my_addr, peer_addr; socklen_t peer_addr_size; sfd = socket(AF_UNIX, SOCK_STREAM, 0); if (sfd == -1) handle_error("socket"); memset(&my_addr, 0, sizeof(struct sockaddr_un)); /* Clear structure */ my_addr.sun_family = AF_UNIX; strncpy(my_addr.sun_path, MY_SOCK_PATH, sizeof(my_addr.sun_path) - 1); if (bind(sfd, (struct sockaddr *) &my_addr, sizeof(struct sockaddr_un)) == -1) handle_error("bind"); if (listen(sfd, LISTEN_BACKLOG) == -1) handle_error("listen"); /* Now we can accept incoming connections one at a time using accept(2) */ peer_addr_size = sizeof(struct sockaddr_un); cfd = accept(sfd, (struct sockaddr *) &peer_addr, &peer_addr_size); if (cfd == -1) handle_error("accept"); /* Code to deal with incoming connection(s)... */ /* When no longer required, the socket pathname, MY_SOCK_PATH should be deleted using unlink(2) or remove(3) */ } SEE ALSO
accept(2), connect(2), getsockname(2), listen(2), socket(2), getaddrinfo(3), getifaddrs(3), ip(7), ipv6(7), path_resolution(7), socket(7), unix(7) COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2007-12-28 BIND(2)
All times are GMT -4. The time now is 02:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy