[petsc-users] Redefining MPI functions as macros can break C++ code

Satish Balay balay at mcs.anl.gov
Thu Nov 3 10:32:14 CDT 2022


And I see the issue got fixed differently [with braces]

https://github.com/AMReX-Codes/amrex/pull/3011/files

Satish

On Wed, 2 Nov 2022, Satish Balay via petsc-users wrote:

> You can define 'PETSC_HAVE_BROKEN_RECURSIVE_MACRO' and then include
> petsc.h in your sources to avoid these macros in amrex/application
> codes.
> 
> PETSc logging is one of the important features - its best to not
> disable it (globally for all) due to this issue.
> 
> Satish
> 
> On Wed, 2 Nov 2022, Erik Schnetter wrote:
> 
> > PETSc redefines MPI functions as macros when logging is enabled. This
> > breaks some C++ code; see e.g. <
> > https://github.com/AMReX-Codes/amrex/pull/3005> for an example. The reason
> > is that macros get confused about commas in template arguments.
> > 
> > It would be convenient if PETSc used a different way to log MPI function
> > calls, but I can't think of a good way. Alternatively, logging could be
> > disabled by default, or MPI logging could be disabled by default, or there
> > could be a simple way to opt out (e.g. use `#define PETSC_LOG_MPI` after
> > `#include <petsc.h>` to enable it for a source file).
> > 
> > -erik
> > 
> > 
> 



More information about the petsc-users mailing list