Declare __STDC_*_MACROS in gmxpre.h
authorTeemu Murtola <teemu.murtola@gmail.com>
Fri, 12 Sep 2014 18:56:32 +0000 (21:56 +0300)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Sat, 13 Sep 2014 03:20:00 +0000 (05:20 +0200)
These free up code that needs, e.g., GMX_INT64_MAX from hard-to-satisfy
constraints on the include order.  More details in the comments in
gmxpre.h.

Also clarify our requirements for C99 support in the install guide.

Change-Id: I371c3a79244340764b320ae36183dd8926fe0f94

docs/install-guide/install-guide.md
src/gmxpre.h
src/gromacs/utility/basedefinitions.h

index 3ce470db15e828f68a464632aed8621b09552f20..095db26641212c0303656e4d8f6fe8c657dd70dc 100644 (file)
@@ -75,6 +75,9 @@ architectures including x86, AMD64/x86-64, PPC, ARM v7 and SPARC VIII.
 
 Technically, GROMACS can be compiled on any platform with an ANSI C99
 and C++98 compiler, and their respective standard C/C++ libraries.
+We use only a few C99 features, but note that the C++ compiler also needs to
+support these C99 features (notably, int64_t and related things), which are not
+part of the C++98 standard.
 Getting good performance on an OS and architecture requires choosing a
 good compiler. In practice, many compilers struggle to do a good job
 optimizing the GROMACS architecture-optimized SIMD kernels.
index 3ae077ecb3fe7247b03ad71fb154a0d4d8115aca..0573e37a11a77bbaf7147b63d6c47920f42016ab 100644 (file)
 #define _GNU_SOURCE 1
 #endif
 
+/* Some C++(?) compilers require these to be defined to get the integer limits
+ * and format specifier macros from stdint.h and inttypes.h, respectively.
+ * The macros are in C99 and C++11, but not in C++98...
+ * As with _GNU_SOURCE, these need to be defined before these headers get first
+ * included.  Unlike _GNU_SOURCE, these headers are included indirectly in most
+ * header and source files (even though the macros are not used that often), so
+ * there is no easy alternative to defining them here, either.
+ * If someone happens to use such a compiler to compile against the installed
+ * Gromacs headers, they need for now take care to define the macros themselves
+ * (as there is no way Gromacs can do that consistently).
+ */
+#define __STDC_LIMIT_MACROS
+#define __STDC_FORMAT_MACROS
+
 #ifdef GMX_FAHCORE
 #define FULLINDIRECT 1
 #define USE_FAH_XDR  1
index 4c554c5f8356080f43645b2337c72babf8a062c3..10ed2c7f6df3d40908406808746e8abd85d84d05 100644 (file)
 
 /* Information about integer data type sizes */
 #include <limits.h>
-#define __STDC_LIMIT_MACROS
 #include <stdint.h>
 #ifndef _MSC_VER
-#define __STDC_FORMAT_MACROS
 #include <inttypes.h>
 #endif