Skip to content

Commit e88b197

Browse files
committed
mpi.h: Move stdint header inclusion outside of extern C block
In C++ mode we try to include <cstdint> so we can annotate fixed-width integer types, but doing so within an extern C block can cause an error. Move these header includes outside of extern C to avoid the issue. Observed on macOS with Xcode 16.2 and CXXFLAGS=-std=gnu++20: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__assertion_handler:29:1: error: templates must have C++ linkage 29 | template <class T> | ^~~~~~~~~~~~~~~~~~ ./src/include/mpi.h:60:1: note: extern "C" language linkage specification begins here 60 | extern "C" { | ^ 1 error generated.
1 parent f763d57 commit e88b197

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/include/mpi.h.in

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@
7777
#define MPICH_CALC_VERSION(MAJOR, MINOR, REVISION, TYPE, PATCH) \
7878
(((MAJOR) * 10000000) + ((MINOR) * 100000) + ((REVISION) * 1000) + ((TYPE) * 100) + (PATCH))
7979

80+
#if !defined(INT8_C)
81+
/* stdint.h was not included, see if we can get it */
82+
# if defined(__cplusplus)
83+
# if __cplusplus >= 201103
84+
# include <cstdint>
85+
# endif
86+
# endif
87+
#endif
88+
89+
#if !defined(INT8_C)
90+
/* stdint.h was not included, see if we can get it */
91+
# if defined(__STDC_VERSION__)
92+
# if __STDC_VERSION__ >= 199901
93+
# include <stdint.h>
94+
# endif
95+
# endif
96+
#endif
97+
8098
/* Keep C++ compilers from getting confused */
8199
#if defined(__cplusplus)
82100
extern "C" {
@@ -105,24 +123,6 @@ extern "C" {
105123
# define MPICH_ATTR_TYPE_TAG_MUST_BE_NULL()
106124
#endif
107125

108-
#if !defined(INT8_C)
109-
/* stdint.h was not included, see if we can get it */
110-
# if defined(__cplusplus)
111-
# if __cplusplus >= 201103
112-
# include <cstdint>
113-
# endif
114-
# endif
115-
#endif
116-
117-
#if !defined(INT8_C)
118-
/* stdint.h was not included, see if we can get it */
119-
# if defined(__STDC_VERSION__)
120-
# if __STDC_VERSION__ >= 199901
121-
# include <stdint.h>
122-
# endif
123-
# endif
124-
#endif
125-
126126
#if defined(INT8_C)
127127
/* stdint.h was included, so we can annotate these types */
128128
# define MPICH_ATTR_TYPE_TAG_STDINT(type) MPICH_ATTR_TYPE_TAG(type)

0 commit comments

Comments
 (0)