[Pyrex] Pyrex/Cython compile error on BSD/Solaris
Robert Bradshaw
robertwb at math.washington.edu
Fri Aug 17 10:49:05 CEST 2007
GCC will complain if one tries to re-declare built-in macros and/or
constants. This prevents the user from declaring c variables with
names like __LINE__ or __GCC__. This also weeds out obscure ones like
_M_IX86 or _B on some platforms. Such names are supposed to be
reserved for any compiler/system header to define.
- Robert
# HG changeset patch
# User Robert Bradshaw <robertwb at math.washington.edu>
# Date 1187340476 25200
# Node ID 05fd5d481a00ef0319b4e05afbeb3972f418a3df
# Parent a5149b1b3ab4dcad0a51e33fd176b209f23c1b03
Raise error when declaring reserved names.
diff -r a5149b1b3ab4 -r 05fd5d481a00 Compiler/Symtab.py
--- a/Compiler/Symtab.py Sun Jul 29 09:38:20 2007 -0700
+++ b/Compiler/Symtab.py Fri Aug 17 01:47:56 2007 -0700
@@ -198,6 +198,9 @@ class Scope:
# Create new entry, and add to dictionary if
# name is not None. Reports a warning if already
# declared.
+ if not self.in_cinclude and re.match("^_[_A-Z]+$", cname):
+ # See http://www.gnu.org/software/libc/manual/html_node/
Reserved-Names.html#Reserved-Names
+ error(pos, "'%s' is a reserved name in C." % cname)
dict = self.entries
if name and dict.has_key(name):
warning(pos, "'%s' redeclared " % name, 0)
More information about the Pyrex
mailing list