This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

#include problems


Hi!

I am in the habit of building packages using a VPATH build in
a subdirectory of the package, like so:

tar xzf foo-x.y.tar.gz
cd foo-x.y
mkdir cygwin
cd cygwin
../configure
make

This no longer works as it used to (at least not with all packages).
I have not bisected when the problem was introduced, but I have
reduced it to this:

configure first creates a config.h in .../foo-x.y/cygwin/config.h

lets fake one with this trivial content:
#define HAVE_NOTHING

some package source file is in .../foo-x.y/src/main.c

lets fake one with this trivial content:
#include "config.h"
#include <stdio.h>
int main(void)
{
	printf("hello world\n");
}

In an autotooled project with subdir objects, you then get this
command run from the .../foo-x.y/cygwin directory when making (I
have removed a bunch of irrelevant gcc options):

gcc -I. -I.. ../src/main.c

*BLAM*

In file included from ../src/main.c:2:
/usr/include/stdio.h:53: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fpos_t’
In file included from ../src/main.c:2:
/usr/include/stdio.h:210: error: expected declaration specifiers or ‘...’ before ‘fpos_t’
/usr/include/stdio.h:216: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
/usr/include/stdio.h:379: error: expected declaration specifiers or ‘...’ before ‘fpos_t’
/usr/include/stdio.h:380: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
/usr/include/stdio.h:535: error: expected declaration specifiers or ‘...’ before ‘fpos_t’
/usr/include/stdio.h:540: error: expected declaration specifiers or ‘...’ before ‘fpos_t’


Running the above with -E gives this output (truncated):

# 1 "../src/main.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "../src/main.c"
# 1 "./config.h" 1
# 2 "../src/main.c" 2
# 1 "/usr/include/stdio.h" 1 3 4
# 29 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/_ansi.h" 1 3 4
# 15 "/usr/include/_ansi.h" 3 4
# 1 "/usr/include/newlib.h" 1 3 4
# 16 "/usr/include/_ansi.h" 2 3 4
# 1 "/usr/include/sys/config.h" 1 3 4



# 1 "/usr/include/machine/ieeefp.h" 1 3 4
# 5 "/usr/include/sys/config.h" 2 3 4
# 1 "/usr/include/sys/features.h" 1 3 4
# 6 "/usr/include/sys/config.h" 2 3 4
# 207 "/usr/include/sys/config.h" 3 4
# 1 "../cygwin/config.h" 1 3 4
# 208 "/usr/include/sys/config.h" 2 3 4
# 17 "/usr/include/_ansi.h" 2 3 4
# 30 "/usr/include/stdio.h" 2 3 4

and the reason can be spotted: /usr/include/sys/config.h tries to
include /usr/include/cygwin/config.h (with #include <cygwin/config.h>)
but gets the config.h from the project instead via the -I.. option
(see the # 1 "../cygwin/config.h" line, near the end).

The -I. and -I.. options are coming from autoconf/automake and the
DEFAULT_INCLUDES variable, so I didn't explicitly specify them in
the real world case I got hit by.

The workaround is trivial, just use a build dir that is named
something !cygwin - or even better - build outside the source tree
instead of beneath it.  But I'm probably not the first to suffer
from this [1] and I'm sure I'm not last...

$ cygcheck -c cygwin gcc4
Cygwin Package Information
Package              Version        Status
cygwin               1.7.9-1        OK
gcc4                 4.3.4-4        OK

Cheers,
Peter

[1] http://www.mail-archive.com/mpir-devel@googlegroups.com/msg03737.html

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]