[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ntohl is not a function
From: |
James Morrison |
Subject: |
ntohl is not a function |
Date: |
Tue, 9 Apr 2002 08:13:28 -0700 (PDT) |
Hi,
I've noticed while compiling the hurd source that gcc3 gives the following
warning:
p++.c:17: warning: operation on `p' may be undefined
p++.c:17: warning: operation on `p' may be undefined
p++.c:17: warning: operation on `p' may be undefined
on the following line:
high = ntohl (*p++);
.
If <netinet.h> is not included then then this warning is not found. Also if
there
are no optimizations then this warning does not occur. From looking at
libc/inet/netinet/in.h and libc/sysdeps/i386/bits/byteswap.h I have decided I
don't know what is causing this warnings, it should be in __bswap_32.
Here is the code I have been using to test this:
#include <stdlib.h>
#include <stdio.h>
#include <netinet/in.h>
int main (int argc, char *argv[])
{
int *p = malloc (12);
int n;
memset (p, 0, 12);
*p++ = 3;
n = ntohl (*p++);
p--;
*p = n;
printf ("%p: %d\n", p, *p);
p--;
printf ("%p:%d\n", p, *p);
return 0;
}
with the following lines to compile it give warnings.
gcc -O3 -Wall -march=i386 -o p++ p++.c
gcc -O3 -Wall -march=i486 -o p++ p++.c
gcc -O3 -Wall -o p++ p++.c
=====
James Morrison
University of Waterloo
Computer Science - Digital Hardware
2A co-op
http://hurd.dyndns.org
Anyone refering this as 'Open Source' shall be eaten by a GNU
__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/
- ntohl is not a function,
James Morrison <=