[petsc-dev] C++11, compatibility versus simplicity
Jed Brown
jedbrown at mcs.anl.gov
Tue Oct 1 08:18:06 CDT 2013
Elemental headers now require C++11, so we have to deal with C++11.
It's worth noting that C++11 is not strictly backward-compatible with
C++03. For example, the following is an error with C++11 due to an
implicit narrowing conversion.
float foo(float x) {
float a[] = {x-.5, x+.5};
return a[0] + a[1];
}
I haven't tried compiling all of PETSc with C++11 enabled, but I think
we'll encounter the narrowing issue above and have to add some casts.
We can do that, but not so for third-party libraries.
The most compatible choice (in terms of having the compiler accept)
would be to add a "dialect" system so that we can compile matelem.cxx
with C++11 support, but other C++ files with an older standard. The
problem with this is that the C++11 ABI (on most compilers) is not
entirely compatible with the C++98 ABI.
http://gcc.gnu.org/wiki/Cxx11AbiCompatibility
This means that to be safe, all libraries in the stack should be
compiled with -std=c++11. So despite the source compatibility issues, I
think we have to make C++11 a global choice and complain to third
parties if they can't build with it.
I think this means adding a package requirescxx11 and adding compiler
detection for the appropriate flags.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20131001/2f805a91/attachment.sig>
More information about the petsc-dev
mailing list