Bison 2.1 on win32 - Mailing list pgsql-hackers

From Magnus Hagander
Subject Bison 2.1 on win32
Date
Msg-id 45FBEF70.8000100@hagander.net
Whole thread Raw
Responses Re: Bison 2.1 on win32  (Andrew Dunstan <andrew@dunslane.net>)
Re: Bison 2.1 on win32  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Bison 2.1 on win32  (Magnus Hagander <magnus@hagander.net>)
List pgsql-hackers
I just tried building with Bison 2.1 on msvc, and it broke. For one
thing, the .BAT file rejects 2.1 as broken instead of 2.0, which is
obviously incorrect :-)

But the generated C file also does not compile causing the error on
http://msdn2.microsoft.com/en-us/library/93az0868.aspx, because msvc
doesn't define __STDC__, which causes Bison to generate code it can't
compile.  Defining __STDC__ globally breaks several other places, since
it affects a lot of include files that aren't necessarily others.

The attached patch seems to fix the build issue. Does it seem
acceptable/the right thing to do?

Another option would be to just reject both 2.0 and 2.1 as broken to
build pg with, I guess...

//Magnus
Index: src/backend/parser/gram.y
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.581
diff -c -r2.581 gram.y
*** src/backend/parser/gram.y    13 Mar 2007 00:33:41 -0000    2.581
--- src/backend/parser/gram.y    17 Mar 2007 13:14:40 -0000
***************
*** 62,67 ****
--- 62,71 ----
  #include "utils/numeric.h"
  #include "utils/xml.h"

+ /* MSVC does not define __STDC__, but Bison 2.1 generates broken code without it */
+ #ifdef WIN32_ONLY_COMPILER
+ #define __STDC__ 1
+ #endif

  /* Location tracking support --- simpler than bison's default */
  #define YYLLOC_DEFAULT(Current, Rhs, N) \
Index: src/backend/bootstrap/bootparse.y
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v
retrieving revision 1.88
diff -c -r1.88 bootparse.y
*** src/backend/bootstrap/bootparse.y    13 Mar 2007 00:33:39 -0000    1.88
--- src/backend/bootstrap/bootparse.y    17 Mar 2007 13:14:56 -0000
***************
*** 51,56 ****
--- 51,61 ----
  #include "tcop/dest.h"
  #include "utils/rel.h"

+ /* MSVC does not define __STDC__, but Bison 2.1 generates broken code without it */
+ #ifdef WIN32_ONLY_COMPILER
+ #define __STDC__ 1
+ #endif
+
  #define atooid(x)    ((Oid) strtoul((x), NULL, 10))


Index: src/pl/plpgsql/src/gram.y
===================================================================
RCS file: /projects/cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v
retrieving revision 1.99
diff -c -r1.99 gram.y
*** src/pl/plpgsql/src/gram.y    19 Feb 2007 03:18:51 -0000    1.99
--- src/pl/plpgsql/src/gram.y    17 Mar 2007 13:15:11 -0000
***************
*** 18,23 ****
--- 18,27 ----

  #include "parser/parser.h"

+ /* MSVC does not define __STDC__, but Bison 2.1 generates broken code without it */
+ #ifdef WIN32_ONLY_COMPILER
+ #define __STDC__ 1
+ #endif

  static PLpgSQL_expr        *read_sql_construct(int until,
                                              int until2,

pgsql-hackers by date:

Previous
From: tomas@tuxteam.de
Date:
Subject: Re: My honours project - databases using dynamically attached entity-properties
Next
From: Andrew Dunstan
Date:
Subject: Re: Bison 2.1 on win32