CVS HEAD is broken by flex

From: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: CVS HEAD is broken by flex
Date: 2007-09-12 01:47:58
Message-ID: 20070912103731.7357.ITAGAKI.TAKAHIRO@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I found CVS HEAD is broken and the following error is reported.
My environment is RHEL4 Update 2 x86_64 with gcc 3.4.4 and flex 2.5.33.

In file included from ../../../src/include/port.h:17,
from ../../../src/include/c.h:841,
from ../../../src/include/postgres_fe.h:21,
from psqlscan.l:40:
/usr/include/netdb.h:560: error: syntax error before '[' token
make[3]: *** [psqlscan.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2

The suspect is flex (or yy template file). It defines "__unused" to
be empty, but netdb.h uses "__unused" as a variable.
I found a similar case from google.
http://mailman.icsi.berkeley.edu/pipermail/xorp-cvs/2007-March/009928.html

[src/bin/psql/psqlscan.c]
9 #if defined(__FreeBSD__)
10 #include <sys/cdefs.h>
11 #else
-> 12 #define __unused
13 #endif

[/usr/include/netdb.h]
552 struct gaicb
553 {
554 const char *ar_name; /* Name to look up. */
555 const char *ar_service; /* Service name. */
556 const struct addrinfo *ar_request; /* Additional request specification. */
557 struct addrinfo *ar_result; /* Pointer to result. */
558 /* The following are internal elements. */
559 int __return;
-> 560 int __unused[5];
561 };

Here is a brute fix for the problem, but it is probably improper.
What is better way to fix?

Index: src/include/port.h
===================================================================
--- src/include/port.h (HEAD)
+++ src/include/port.h (working copy)
@@ -13,6 +13,7 @@
#ifndef PG_PORT_H
#define PG_PORT_H

+#undef __unused
#include <ctype.h>
#include <netdb.h>
#include <pwd.h>

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeremy Drake 2007-09-12 02:47:34 buildfarm failure after ICC configure change
Previous Message Alvaro Herrera 2007-09-12 01:35:40 Re: pg_dump and money type