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 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>
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.
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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:...
|
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...
|
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,...
|
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...
|
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,...
|
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:
|
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,...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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...
| |