[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
sys/stat.h and nlink
From: |
Simon Josefsson |
Subject: |
sys/stat.h and nlink |
Date: |
Wed, 14 Jan 2009 16:44:39 +0100 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) |
The test-sys_stat self-test fails on debian etch x86, see:
http://autobuild.josefsson.org/gnulib/log-200901140954236318000.txt
The problem is that sys/stat.h does not define nlink_t (at least not
unconditionally), however sys/types.h does:
address@hidden:~$ cat>foo.c
#include <sys/stat.h>
int main (void) { nlink_t foo; }
address@hidden:~$ gcc -o foo foo.c
foo.c: In function 'main':
foo.c:2: error: 'nlink_t' undeclared (first use in this function)
foo.c:2: error: (Each undeclared identifier is reported only once
foo.c:2: error: for each function it appears in.)
foo.c:2: error: expected ';' before 'foo'
address@hidden:~$ cat>bar.c
#include <sys/types.h>
int main (void) { nlink_t foo; }
address@hidden:~$ gcc -o bar bar.c
I see two solutions. I pushed 2). Thoughts?
1) Work around for the self-test only. Disadvantage: does not provide
nlink_t to application that (correctly) expects nlink_t to be provided
by sys/stat.h.
diff --git a/tests/test-sys_stat.c b/tests/test-sys_stat.c
index 4b5eb76..3b5aab1 100644
--- a/tests/test-sys_stat.c
+++ b/tests/test-sys_stat.c
@@ -18,6 +18,7 @@
#include <config.h>
+#include <sys/types.h>
#include <sys/stat.h>
#include "verify.h"
2) sys_stat_h.m4 should detect the situation, and make the replacement
sys/stat.h header provide a nlink_t. The easiest way to provide this
replacement without causing conflicts appears to be to include
sys/types.h, so we might as well do that unconditionally. This seems to
be the same as in many other *.in.h files.
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index a526833..da965d0 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -35,6 +35,9 @@
#ifndef _GL_SYS_STAT_H
+/* Get nlink_t. */
+#include <sys/types.h>
+
/* The include_next requires a split double-inclusion guard. */
address@hidden@ @NEXT_SYS_STAT_H@
/Simon
- sys/stat.h and nlink,
Simon Josefsson <=