This mail could probably be considered a followup to this thread
introduced by Rolf Vandevaart from Sun back in Jan 2009:
http://lists.gnu.org/archive/html/bug-autoconf/2009-01/msg00056.html
Short version:
--------------
Is there any chance that an AC_CXX_RESTRICT macro will ever come into
existence, and/or the output from AC_C_RESTRICT will become safe for
both C/C++? Specifically, Open MPI uses the "restrict" keyword in a
header file that is included in both C and C++ source code; we now
have a problem if the support for "restrict" is different between the
C and C++ compiler.
More details:
-------------
As Rolf noted in the earlier thread, the Sun compiler suite has
different support for "restrict" in its C and C++ compiler (i.e., the
C compiler supports some "restrict"-like keywords, but the C++
compiler does not). I have been told that "restrict" is not defined
in the C++ language, so I can understand the Sun compiler making this
interpretation. We (the Open MPI project) have recently found another
compiler that has different support for restrict in its C and C++
compilers: the PGI Linux compiler suite.
It seems that AC_C_RESTRICT can sometimes find "restrict" for the PGI
C compiler, but it can sometimes find "__restrict". Both of these
values work for the PGI C compiler, but only "__restrict" works for
the PGI C++ compiler. The reasons for AC's difference in answers
appear to do with the PGI C compiler installation and the version of
the GCC/glibc installed, distro/version, ...etc. I didn't delve too
deeply to figure out why this happened. See the thread starting here
for more details:
http://www.open-mpi.org/community/lists/users/2009/03/8402.php
This causes a problem for us because Open MPI has a C header file that
uses "restrict" and relies on AC_C_RESTRICT to do the Right Thing.
Across all of our C source code, this works great. When this header
file is included in C++ source code, bad things *may* happen -- by
what Rolf noted, and now if AC_C_RESTRICT chose "restrict" instead of
"__restrict".
Rolf solved the problem by putting a hackaround in for the Sun
compiler. But now that there's a second compiler suite that falls
into the same category as the Sun compiler, I'm wondering if Autoconf
shouldn't try to address this issue...? E.g.:
- should there be an AC_CXX_RESTRICT test? E.g., perhaps the output
of AC_C_RESTRICT and AC_CXX_RESTRICT tests would be protected with
appropriate #if's that determine if you're compiling in C or C++.
- Or should there be a new AC_RESTRICT test that makes a solution for
both the C and C++ compilers?
- Or ...?
(please reply all so that the others CC'ed on this post also see the
followups; thanks!)
--
Jeff Squyres
Cisco Systems