From: jeremy siek Date: Thu, 29 Apr 1999 09:28:00 -0500 (EST) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: mpi-bind@XXXXXXXXXXX,mpi-core@XXXXXXXXXXX,mpi-io@XXXXXXXXXXX Cc: HOLZHEU@XXXXXXXXXX,lumesdaine.1@XXXXXX,jsquyres@XXXXXXXXXX,Subject: C++ MPI constants In-Reply-To: References: X-Mailer: VM 6.40 under Emacs 19.34.1 Reply-To: Jeremy Siek Sender: owner-mpi-core@XXXXXXXXXXX Precedence: bulk X-UIDL: 4d21823cd6255070577b022cd04418b8 Michael Holzheu has brought to our attention a name conflict between some macros in stdio.h (SEEK_SET, etc.) and the C++ MPI constants. He proposes two solutions. 1. Change all the C++ constants to lowercase, which would be more in conformance with the style of the C++ standard libraries. 2. Change just the offending constants by adding a "CPP_" prefix. Andrew Lumsdaine and I suggest that alternative #1 is the better choice. I have included below the original email that details the problem. Regards, Jeremy Siek HOLZHEU@XXXXXXXXXX writes: > The problem was, that SEEK_SET, SEEK_CUR and SEEK_END are macros which are > defined > also in "stdio.h". This means that a user cannot use MPI::SEEK_XXX when he > included stdio.h, > because the preprocessor replaces the SEEK_XXX parts: > > in stdio.h > ========== > > #define SEEK_SET 0 > > > in mpi.h > ======== > > #define MPI_SEEK_SET 0 /* the C MPI constant */ > > ... > > class MPI > { > > .... > > enum > { > SEEK_SET = MPI_SEEK_SET, <<<<< will be replaced if stdio.h has > been included before > and becomes "0 = 0" ---> Syntax > Error > }; > > in the user program > =================== > .... > fh.Seek(0, MPI::SEEK_SET); <<<< becomes "fh.Seek(0,MPI::0)" and generates > a > syntax error when we compile > > > The problem is of course more general and perhaps not only the > MPI::SEEK_XXX constants are affected. > Because we have no MPI_-Prefix in the C++ bindings and all constants are > uppercase the probablility > of conflicts with preprecessor macros is quite high. > > I see the following alternatives to solve this problem: > > 1. We define all C++ MPI-constants lowercase (e.g. MPI::seek_set, > MPI::seek_cur etc.). > Because by convention preprocessor macros (especially in standard > includes) are uppercase > the probablility of conflicts is very low. Other C++ APIs like e.g. C++ > IO-streams (think of > ios::showpos, ios::left etc.) or Corba do it in this way, too. I think > this would be the > best solution. But of course I know this will alter the standard in a > very significant way... > > 2. We have to find all Constants which conflict with standard include > macros and alter their names. > I think the best way to do this is to put a prefix in front of them > (e.g. "CPP" or something > like that). > > We know at the moment the three canditates: > > MPI::SEEK_SET --> MPI::CPP_SEEK_SET > MPI::SEEK_CUR --> MPI::CPP_SEEK_CUR > MPI::SEEK_END --> MPI::CPP_SEEK_END > > The problem of this solution if of course that we cannot know which > macros will be defined in > the future... > > ------------------------------------------------------------------------ Jeremy Siek Graduate Research Assistant email: jsiek@XXXXXXXXXX Dept. Comp. Sci. & Eng. phone: (219) 631-3906 325 Cushing Hall fax: (219) 631-9260 University of Notre Dame www: http://www.lsc.nd.edu/~jsiek/ Notre Dame, IN 46556 ------------------------------------------------------------------------