473,385 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problems using getaddrinfo and friends using c99 standard

Hi,

I'm trying to do some network programming, but when I use 'struct
addrinfo' or getaddrinfo, I see errors:
[ ~/src/_sandbox] gcc --std=c99 -Wall ipv6_test.c -o it
ipv6_test.c: In function `main':
ipv6_test.c:25: error: storage size of 'hints' isn't known
ipv6_test.c:34: warning: implicit declaration of function
`getaddrinfo'
ipv6_test.c:38: error: dereferencing pointer to incomplete type
ipv6_test.c:39: error: dereferencing pointer to incomplete type
ipv6_test.c:40: error: dereferencing pointer to incomplete type
ipv6_test.c:41: error: dereferencing pointer to incomplete type
ipv6_test.c:49: error: dereferencing pointer to incomplete type
ipv6_test.c:49: error: dereferencing pointer to incomplete type
ipv6_test.c:49: error: dereferencing pointer to incomplete type
ipv6_test.c:56: warning: implicit declaration of function
`gai_strerror'
ipv6_test.c:56: warning: format argument is not a pointer (arg 4)
ipv6_test.c:71: error: dereferencing pointer to incomplete type
ipv6_test.c:71: error: dereferencing pointer to incomplete type
ipv6_test.c:77: warning: implicit declaration of function
`freeaddrinfo'
ipv6_test.c:25: warning: unused variable `hints'

However, it builds fine when I remove --std-c99

Does anyone know the reason for this?

Thanks,
Nathan
Jun 27 '08 #1
3 8223
On 18 Jun 2008 at 18:54, Nathan wrote:
I'm trying to do some network programming, but when I use 'struct
addrinfo' or getaddrinfo, I see errors:
[snip]
ipv6_test.c:34: warning: implicit declaration of function `getaddrinfo'
[snip]
ipv6_test.c:56: warning: implicit declaration of function `gai_strerror'
[snip]
ipv6_test.c:77: warning: implicit declaration of function `freeaddrinfo'
You're probably not including the reqired headers. Try

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>

Jun 27 '08 #2
On Wed, 18 Jun 2008 20:17:21 +0000, Antoninus Twink wrote:
On 18 Jun 2008 at 18:54, Nathan wrote:
>I'm trying to do some network programming, but when I use 'struct
addrinfo' or getaddrinfo, I see errors:
[snip]
>ipv6_test.c:34: warning: implicit declaration of function `getaddrinfo'
[snip]
>ipv6_test.c:56: warning: implicit declaration of function
`gai_strerror'
[snip]
>ipv6_test.c:77: warning: implicit declaration of function
`freeaddrinfo'

You're probably not including the reqired headers. Try

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
The OP probably is including the required headers, or the compiler would
also have complained without the --std-c99 option. The answer is simply
that getaddrinfo is not a C99 function, and is therefore not declared by
the library when asking for a C99 implementation.
Jun 27 '08 #3
On 18 Jun 2008 at 20:37, Harald van Dijk wrote:
The OP probably is including the required headers, or the compiler would
also have complained without the --std-c99 option. The answer is simply
that getaddrinfo is not a C99 function, and is therefore not declared by
the library when asking for a C99 implementation.
I think you're right. That seems like a terrible misfeature of gcc. If I
have a C program and I include a POSIX header, I damn well want the
functions from that header, in just the same way as if I include my own
header file then I want access to those functions, without the compiler
getting all holier-than-thou and telling me my functions aren't
mentioned in the C standard.

One solution is to add -D_POSIX_C_SOURCE=200112L as a command-line
option.

Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Minor Crank | last post by:
Sorry for the silly newbie question. Our manager has directed us to use the getaddrinfo() instead of the deprecated gethostbyname(). The problem is, I don't know where getaddrinfo() get its...
1
by: run | last post by:
My enveronment - IE6 - .Net 1.1 sp1 - Windows 2000 sp4 I cannot use function "CSMTPConnection" on Vc++.Net on Windows 2000. because WS2_32.dll on error message as "The procedure entry point...
0
by: Vidyasagara Guntaka | last post by:
Hi, I recently downloaded source code for 8.0.0 beta1. When I tried building the libpq for windows, I got some compilation errors. Following the compilation output:...
4
by: edcdave | last post by:
I'm trying to get MoinMoin 1.5.4 running with Python 2.3.4 (installed from an SCO Skunkworks binary). Python 2.3.4 (#1, Aug 27 2004, 18:22:39) on sco_sv3 One of the MoinMoin modules attempts to...
1
by: mirandacascade | last post by:
I noticed the following lines from the connect() method of the HTTPConnection class within httplib: for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM): af, socktype,...
3
by: Thomas Dybdahl Ahle | last post by:
Hi, I'm writing an application that connects to the internet. Something like this: for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res...
2
by: John Nagle | last post by:
Here's a strange little bug. "socket.getaddrinfo" blows up if given a bad domain name containing ".." in Unicode. The same string in ASCII produces the correct "gaierror" exception. Actually,...
4
by: Eric Lilja | last post by:
Hello, consider this program: class Outer { public: class Base { friend class Outer; public: Base(int n) : n_(n) {} protected:
1
by: Karl Chen | last post by:
I've discovered that since glibc 2.3.2, getaddrinfo(3) supports a useful flag called AI_ADDRCONFIG. It turns off AAAA lookups if the machine isn't configured for IPv6 (and similarly for IPv4,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.