Skip to content

Fix triutils for FreeBsd

Created by: tvrusso

On FreeBSD 10, which uses clang as its default compiler, the Triutils package will not compile if C++11 is enabled. This is because on that system, when building on 64-bit machines the "sys/_null.h" header defines NULL not as 0, but as either "nullptr", "__null", "0L", or "(void *) 0" depending on how it's being included. Peppered throughout packages/triutils/Trilinos_Util_iohb.c is this sort of pattern:

    char somearray[somesize];
    somearray[someindex] = (char) NULL;

which is clearly intended to null-terminate a string. This fails to compile, because one is casting a 64-bit pointer down to 8 bits, and clang hates that (but only when invoked with -std=c++11).

Changing these uses of "NULL" to uses of the null character '\0' allows Trilinos_Util_iohb.cpp to compile just fine, and should be completely portable across all platforms.

I'm marking this as a change off of the trilinos-release-12-6-branch because it impacts building Xyce on FreeBSD with C++11, and Xyce is currently building with 12.6.3, not master. The fix should be applied to both master and the 12-6 branch, so Xyce can use future 12.6.x releases on this platform using C++11.

Merge request reports