You are not logged in.

#1 2008-08-15 18:42:05

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

#include question -- limits.h

I maintain moblock package in AUR, and currently it doesn't compile (see http://bugs.archlinux.org/task/10728), it gives this error:

gcc -Wall -O2 -march=i586 -mtune=i686 -fomit-frame-pointer -ffast-math -D_GNU_SOURCE -DNFQUEUE -L/usr/include/libipq -c -o MoBlock.o MoBlock.c
In file included from MoBlock.c:35:
/usr/include/linux/netfilter_ipv4.h:53: error: ?INT_MIN? undeclared here (not in a function)
/usr/include/linux/netfilter_ipv4.h:63: error: ?INT_MAX? undeclared here (not in a function)
make: *** [MoBlock.o] Error 1

I did some research and found a possible solution to the problem; it involves adding one "#include" line to MoBlock.c, so the code looks like this:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/in.h>
#include <string.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <limits.h>     ==>>  ADDED LINE
#include <linux/netfilter_ipv4.h>
#include <signal.h>
#include <regex.h>

This makes it possible to compile moblock, but since I don't know anything about C I'm not sure if this is a safe thing to do, so I'm hesitant about upgrading the AUR package to include this fix.  Any ideas?

I'll post the same question on the moblock bugracker, but the author is usually very slow to respond, if he responds at all, so in the meantime any additional info would be very helpful.

Offline

#2 2008-08-15 19:02:21

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: #include question -- limits.h

I don't know *anything* about this stuff, but after googling, I found this :
http://lists.netfilter.org/pipermail/ne … 03482.html
(read the two answers too)

And the second patch was commited by Rusty Russel to iptables :
http://git.netfilter.org/cgi-bin/gitweb … 05eec8f268

Also the header of /usr/include/linux/netfilter_ipv4.h :

/* IPv4-specific defines for netfilter. 
 * (C)1998 Rusty Russell -- This code is GPL.
 */

So I would say you are fine doing that.

However I was a bit puzzled by Rusty's answer. If I understood correctly, he said that header was not supposed to be used in userspace. And yet, it is still used now.
I believe I found the explanation there : http://lwn.net/Articles/113349/
To sum up, you are not supposed to use kernel headers, but sometimes you just don't have the choice.


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#3 2008-08-15 19:13:04

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: #include question -- limits.h

Awesome info/links.  Thanks shining!

Offline

Board footer

Powered by FluxBB