-1

To set so called feature flags in our code we use an external file. There we define the macro

#define LB

We just ported our software to C++ and then the errors came, specificially this one

/usr/local/openmpi-1.6.4/include/openmpi/ompi/mpi/cxx/constants.h:174:28: error: declaration does not declare anything [-fpermissive]

Looking it up in the corresponding file brought up that OpenMPI uses an internal datatype called LB.

OMPI_DECLSPEC extern const Datatype LB;

How can I avoid the name conflict? Renaming the macro #define LB is not an option as this destroys backwards compatibility. Is it possible to use the C-Interface of OpenMPI with C++?

Henri Menke
  • 10,705
  • 1
  • 24
  • 42
  • A possible dirty hack could be `#define LB LB`. – Henri Menke Mar 08 '13 at 10:56
  • 1
    The cleanest way would be to make sure that the `#define` appears *after* the `#include`ed OpenMPI headers in the translation unit. – Michael Wild Mar 08 '13 at 11:06
  • @Michael Wild: Unfortunately this is not possible as `mpi.h` gets included in too many files and the feature flags are parsed in the beginning to make turn the features on or off. – Henri Menke Mar 08 '13 at 12:18

2 Answers2

1

LB is part of the official MPI C++ bindings. You can't turn it off without turning off the entire set of C++ bindings.

But note that the MPI "LB" is in the MPI:: namespace. So you could also make your LB be an actual constant (vs. a #define) -- maybe something like this in your header file:

extern const int LB;

(and then you have to actually instantiate that const int LB somewhere, of course)

This would make an LB constant that is outside of the MPI namespace, and therefore wouldn't conflict.

Jeff Squyres
  • 744
  • 4
  • 6
  • This is quite a good idea, but the program has to be backwards compatible. Furthermore `#define LB` is part of the user interface (to set/unset features when compiling) and users hate changes. – Henri Menke Mar 10 '13 at 23:57
  • 1
    Without some kind if clever/dangerous workaround, you might well be stuck. Unfortunately, MPI has had MPI::LB since 1996. If you're only using C++ and not the MPI C++ bindings, you can turn off Open MPI's C++ bindings. – Jeff Squyres Mar 11 '13 at 11:35
0

One can disable the OpenMPI C++ Bindings by using the macro

#define OMPI_SKIP_MPICXX
Henri Menke
  • 10,705
  • 1
  • 24
  • 42