Bug and fix, reopened: "restrict" #define fails on VC
tege at swox.com
Mon Apr 10 15:19:25 CEST 2006
<librik at panix.com> writes:
I'm afraid I have to report that a configure bug, fixed four
years ago in GMP 4.1, has crept back in to the latest GMP 4.2
sources. (I know this because I reported the bug at the time,
and Kevin Ryde fixed it.)
Unfortunately most of the 2002 archives have vanished from
SWOX's list-archives, but I have the report and reply here,
and have reproduced them below.
In short: creating the "#define restrict __restrict" macro in
config.h is unsafe on compilers like Visual C 2005 that support
both the "__restrict" keyword and the "declspec(restrict)" syntax
in header files. The correct solution is to use a unique macro
name like "gmp_restrict". As Kevin noted, "restrict is in the
compiler's namespace these days."
Unfortunately, Kevin's fix was to stop defining restrict since it
wasn't actually used in the GMP sources. Now it is, and it will
become much more used in future GMP releases.
What files in GMP are affected? I suppose it would work just to
reorder #include order.
More information about the gmp-bugs