Skip to content

Commit c39426e

Browse files
committed
mpi.h.in: use C++ static_cast<> where appropriate
When compiling mpi.h with a modern C++ compiler and a high degree of pickyness (e.g., -Wold-style-cast), casting using (void*) in the OMPI_PREDEFINED_GLOBAL and MPI_STATUS*_IGNORE macros will emit warnings. So if we're compiling with a C++ compiler, use C++'s static_cast<> instead of (void*). Thanks to @shadow-fax for identifying the issue. Signed-off-by: Jeff Squyres <[email protected]> (cherry picked from commit 30afdce)
1 parent fb39c7f commit c39426e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ompi/include/mpi.h.in

Lines changed: 10 additions & 1 deletion
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-2018 Cisco Systems, Inc. All rights reserved
12+
* Copyright (c) 2007-2019 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.
@@ -325,7 +325,11 @@
325325
* when building OMPI).
326326
*/
327327
#if !OMPI_BUILDING
328+
#if defined(c_plusplus) || defined(__cplusplus)
329+
#define OMPI_PREDEFINED_GLOBAL(type, global) (static_cast<type> (static_cast<void *> (&(global))))
330+
#else
328331
#define OMPI_PREDEFINED_GLOBAL(type, global) ((type) ((void *) &(global)))
332+
#endif
329333
#else
330334
#define OMPI_PREDEFINED_GLOBAL(type, global) ((type) &(global))
331335
#endif
@@ -765,8 +769,13 @@ enum {
765769
*/
766770
#define MPI_INFO_ENV OMPI_PREDEFINED_GLOBAL(MPI_Info, ompi_mpi_info_env)
767771

772+
#if defined(c_plusplus) || defined(__cplusplus)
773+
#define MPI_STATUS_IGNORE (static_cast<MPI_Status *> (0))
774+
#define MPI_STATUSES_IGNORE (static_cast<MPI_Status *> (0))
775+
#else
768776
#define MPI_STATUS_IGNORE ((MPI_Status *) 0)
769777
#define MPI_STATUSES_IGNORE ((MPI_Status *) 0)
778+
#endif
770779

771780
/*
772781
* Special MPI_T handles

0 commit comments

Comments
 (0)