[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Is this a bug with glibc (ntohl, ntohs, ...)?



What happens if you change the order of the include files to move
<linux/cdrom.h> below <netinet/in.h>?

It's difficult to call this a glibc bug; the issue is that both the kernel
(which uses the headers form /usr/include/linux) and userspace programs need
to know about ntohs/ntohl, so it must be declared in both places.  By
including <linux/cdrom.h>, you introduce both Linux and glibc headers into the
mix, which isn't necessarily guaranteed to work.

Steve Langasek
postmodern programmer

On Sun, 18 Mar 2001, Eray Ozkural wrote:

> Hi,

> I was trying to compile a program. In a header the following preprocessor
> includes are employed

> #include <cstdio>
> #include <cstdlib>
> #include <unistd.h>
> #include <sys/ioctl.h>
> #include <sys/file.h>
> #include <sys/types.h>
> #include <fcntl.h>
> #include <string>
> #include <linux/cdrom.h>
> #include <signal.h>
> #include <netinet/in.h>
> <snip>

> I get the following error messages:

> In file included from vcd.h:31,
>                  from vcd.cpp:18:
> /usr/include/netinet/in.h:285: warning: `ntohl' redefined
> /usr/include/linux/byteorder/generic.h:169: warning: this is the location of the previous definition
> /usr/include/netinet/in.h:286: warning: `ntohs' redefined
> /usr/include/linux/byteorder/generic.h:175: warning: this is the location of the previous definition
> /usr/include/netinet/in.h:287: warning: `htonl' redefined
> /usr/include/linux/byteorder/generic.h:168: warning: this is the location of the previous definition
> /usr/include/netinet/in.h:288: warning: `htons' redefined
> /usr/include/linux/byteorder/generic.h:174: warning: this is the location of the previous definition
> In file included from vcd.h:31,
>                  from vcd.cpp:18:
> /usr/include/netinet/in.h:259: parse error before `)'
> /usr/include/netinet/in.h:259: parse error before `?'
> /usr/include/netinet/in.h:259: parse error before `)'
> /usr/include/netinet/in.h:260: parse error before `)'
> /usr/include/netinet/in.h:260: parse error before `?'
> /usr/include/netinet/in.h:260: parse error before `)'
> /usr/include/netinet/in.h:262: parse error before `)'
> /usr/include/netinet/in.h:262: parse error before `?'
> /usr/include/netinet/in.h:262: parse error before `)'
> /usr/include/netinet/in.h:264: parse error before `)'
> /usr/include/netinet/in.h:264: parse error before `?'
> /usr/include/netinet/in.h:264: parse error before `)'
> In file included from vcd.h:31,
>                  from vcd.cpp:18:
> /usr/include/netinet/in.h:367: parse error before `}'

> Could someone please reproduce this?

> Since the files in which the byteorder conversion routines
> are defined happen to be both in glibc, I want to ask
> whether it is a bug with glibc or this particular program.
> It is in C++ but I guess it would recur with C.

> The program is mpegorion, you can check it out from their
> home page creworion.net If I can get it to run I'm going to
> ITP it... So, this is a tentative ITP. Not many proper VCD/DVD
> players in Debian. :/ What a waste of time.

> I had encountered similar "previously defined" errors in the past
> while compiling a kernel module. I'd assumed that it was an error
> of that code, but now that I see it again...

> I'm not on the list, please Cc: to me.

> Thanks,

> Note 1:
> orion:mpeg_orion$ dpkg -s libc6-dev
> Package: libc6-dev
> Status: install ok installed
> Priority: standard
> Section: devel
> Installed-Size: 9298
> Maintainer: Ben Collins <bcollins@debian.org>
> Source: glibc
> Version: 2.2.2-1
> ...

> Note 2:
> The kernel module was 3com's 3c90x driver, I was trying to port it
> to 2.4 You can obtain the driver code from 3com's related web page.



Reply to: