Skip to content

Commit 283cfbf

Browse files
authored
Merge pull request #7817 from jsquyres/pr/protect-stdc-version
mpi.h.in: protect checking __STDC_VERSION__
2 parents d6f5700 + d522c27 commit 283cfbf

File tree

1 file changed

+42
-24
lines changed

1 file changed

+42
-24
lines changed

ompi/include/mpi.h.in

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2007-2019 Cisco Systems, Inc. All rights reserved
12+
* Copyright (c) 2007-2020 Cisco Systems, Inc. All rights reserved
1313
* Copyright (c) 2008-2009 Sun Microsystems, Inc. All rights reserved.
1414
* Copyright (c) 2009-2012 Oak Rigde National Laboratory. All rights reserved.
1515
* Copyright (c) 2011 Sandia National Laboratories. All rights reserved.
@@ -242,8 +242,7 @@
242242
* only relevant if we're not building Open MPI (i.e., we're compiling an
243243
* MPI application).
244244
*/
245-
#if !OMPI_BUILDING \
246-
245+
#if !OMPI_BUILDING
247246
/*
248247
* Figure out which compiler is being invoked (in order to compare if
249248
* it was different than what OMPI was built with).
@@ -276,11 +275,12 @@
276275
* just emit a compiletime warning (via the deprecation function
277276
* attribute) that they're using an MPI1 removed function.
278277
*
279-
* Otherwise, we'd like to issue a fatal error directing the user
280-
* that they've used an MPI1 removed function. If the user's
281-
* compiler supports C11 _Static_assert feature, we #define
282-
* the MPI routines to instead be a call to _Static_assert
283-
* with an appropriate message suggesting the new MPI3 equivalent.
278+
* Otherwise, we'd like to issue a fatal error directing the
279+
* user that they've used an MPI1 removed function. If the
280+
* user's compiler supports C11 _Static_assert() or
281+
* C++11 static_assert(), we #define the MPI routines to
282+
* instead be a call to an assert with an appropriate message
283+
* suggesting the new MPI3 equivalent.
284284
*
285285
* Otherwise, if the user's compiler supports the error function
286286
* attribute, define the MPI routines with that error attribute.
@@ -296,13 +296,28 @@
296296
# define OMPI_OMIT_MPI1_COMPAT_DECLS 0
297297
# define OMPI_REMOVED_USE_STATIC_ASSERT 0
298298
# define __mpi_interface_removed__(func, newfunc) __mpi_interface_deprecated__(#func " was removed in MPI-3.0. Use " #newfunc " instead. continuing...")
299-
# elif (__STDC_VERSION__ >= 201112L)
299+
# elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
300+
/* This is the C11 (or later) case, which uses
301+
_Static_assert() */
300302
# define OMPI_OMIT_MPI1_COMPAT_DECLS 1
301303
# define OMPI_REMOVED_USE_STATIC_ASSERT 1
302-
// This macro definition may show up in compiler output. So we both
303-
// outdent it back to column 0 and give it a user-friendly name to
304-
// help users grok what we are trying to tell them here.
305-
#define THIS_SYMBOL_WAS_REMOVED_IN_MPI30(func, newfunc) _Static_assert(0, #func " was removed in MPI-3.0. Use " #newfunc " instead.")
304+
/* This macro definition may show up in compiler output. So we both
305+
* outdent it back to column 0 and give it a user-friendly name to
306+
* help users grok what we are trying to tell them here.
307+
*/
308+
#define THIS_SYMBOL_WAS_REMOVED_IN_MPI30(symbol, new_symbol) 0; _Static_assert(0, #symbol " was removed in MPI-3.0. Use " #new_symbol " instead.")
309+
#define THIS_FUNCTION_WAS_REMOVED_IN_MPI30(func, newfunc) _Static_assert(0, #func " was removed in MPI-3.0. Use " #newfunc " instead.")
310+
# elif defined(__cplusplus) && (__cplusplus >= 201103L)
311+
/* This is the C++11 (or later) case, which uses
312+
static_assert() */
313+
# define OMPI_OMIT_MPI1_COMPAT_DECLS 1
314+
# define OMPI_REMOVED_USE_STATIC_ASSERT 1
315+
/* This macro definition may show up in compiler output. So we both
316+
* outdent it back to column 0 and give it a user-friendly name to
317+
* help users grok what we are trying to tell them here.
318+
*/
319+
#define THIS_SYMBOL_WAS_REMOVED_IN_MPI30(symbol, new_symbol) 0; static_assert(0, #symbol " was removed in MPI-3.0. Use " #new_symbol " instead.")
320+
#define THIS_FUNCTION_WAS_REMOVED_IN_MPI30(func, newfunc) static_assert(0, #func " was removed in MPI-3.0. Use " #newfunc " instead.")
306321
# elif OPAL_HAVE_ATTRIBUTE_ERROR
307322
# define OMPI_OMIT_MPI1_COMPAT_DECLS 0
308323
# define OMPI_REMOVED_USE_STATIC_ASSERT 0
@@ -328,7 +343,10 @@
328343
#endif
329344

330345
#if !defined(THIS_SYMBOL_WAS_REMOVED_IN_MPI30)
331-
# define THIS_SYMBOL_WAS_REMOVED_IN_MPI30(func, newfunc)
346+
# define THIS_SYMBOL_WAS_REMOVED_IN_MPI30(symbol, newsymbol)
347+
#endif
348+
#if !defined(THIS_FUNCTION_WAS_REMOVED_IN_MPI30)
349+
# define THIS_FUNCTION_WAS_REMOVED_IN_MPI30(func, newfunc)
332350
#endif
333351

334352
#if !defined(OMPI_REMOVED_USE_STATIC_ASSERT)
@@ -2802,16 +2820,16 @@ OMPI_DECLSPEC int PMPI_Type_ub(MPI_Datatype mtype, MPI_Aint *ub)
28022820
#endif /* !OMPI_OMIT_MPI1_COMPAT_DECLS */
28032821

28042822
#if OMPI_REMOVED_USE_STATIC_ASSERT
2805-
#define MPI_Address(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Address, MPI_Get_address)
2806-
#define MPI_Errhandler_create(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Errhandler_create, MPI_Comm_create_errhandler)
2807-
#define MPI_Errhandler_get(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Errhandler_get, MPI_Comm_get_errhandler)
2808-
#define MPI_Errhandler_set(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Errhandler_set, MPI_Comm_set_errhandler)
2809-
#define MPI_Type_extent(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Type_extent, MPI_Type_get_extent)
2810-
#define MPI_Type_hindexed(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Type_hindexed, MPI_Type_create_hindexed)
2811-
#define MPI_Type_hvector(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Type_hvector, MPI_Type_create_hvector)
2812-
#define MPI_Type_lb(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Type_lb, MPI_Type_get_extent)
2813-
#define MPI_Type_struct(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Type_struct, MPI_Type_create_struct)
2814-
#define MPI_Type_ub(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Type_ub, MPI_Type_get_extent)
2823+
#define MPI_Address(...) THIS_FUNCTION_WAS_REMOVED_IN_MPI30(MPI_Address, MPI_Get_address)
2824+
#define MPI_Errhandler_create(...) THIS_FUNCTION_WAS_REMOVED_IN_MPI30(MPI_Errhandler_create, MPI_Comm_create_errhandler)
2825+
#define MPI_Errhandler_get(...) THIS_FUNCTION_WAS_REMOVED_IN_MPI30(MPI_Errhandler_get, MPI_Comm_get_errhandler)
2826+
#define MPI_Errhandler_set(...) THIS_FUNCTION_WAS_REMOVED_IN_MPI30(MPI_Errhandler_set, MPI_Comm_set_errhandler)
2827+
#define MPI_Type_extent(...) THIS_FUNCTION_WAS_REMOVED_IN_MPI30(MPI_Type_extent, MPI_Type_get_extent)
2828+
#define MPI_Type_hindexed(...) THIS_FUNCTION_WAS_REMOVED_IN_MPI30(MPI_Type_hindexed, MPI_Type_create_hindexed)
2829+
#define MPI_Type_hvector(...) THIS_FUNCTION_WAS_REMOVED_IN_MPI30(MPI_Type_hvector, MPI_Type_create_hvector)
2830+
#define MPI_Type_lb(...) THIS_FUNCTION_WAS_REMOVED_IN_MPI30(MPI_Type_lb, MPI_Type_get_extent)
2831+
#define MPI_Type_struct(...) THIS_FUNCTION_WAS_REMOVED_IN_MPI30(MPI_Type_struct, MPI_Type_create_struct)
2832+
#define MPI_Type_ub(...) THIS_FUNCTION_WAS_REMOVED_IN_MPI30(MPI_Type_ub, MPI_Type_get_extent)
28152833
#endif
28162834

28172835
#if defined(c_plusplus) || defined(__cplusplus)

0 commit comments

Comments
 (0)