[petsc-dev] Preprocessor hell: #define VecType

Chetan Jhurani chetan.jhurani at gmail.com
Fri Sep 28 12:33:04 CDT 2012

> -----Original Message-----
> From: petsc-dev-bounces at mcs.anl.gov [mailto:petsc-dev-bounces at mcs.anl.gov] On Behalf Of Karl Rupp
> Sent: Friday, September 28, 2012 9:59 AM
> To: For users of the development version of PETSc
> Subject: Re: [petsc-dev] Preprocessor hell: #define VecType
> Hi,
> > You are missing the fact that all PetscObjects have an implementation
> > type and it is a string, and there is
> > one of these #defines for every class.
> Ok, thanks for shedding light on that.
> > However, I would support namespacing all these Types since they are not
> > in heavy use, e.g. PetscVecType, PetscMatType.
> I assume that any compiler errors would be a LOT clearer if VecType were
> at least a typedef instead of a brutal preprocessor-define. Without

There won't be any error in compiling

	template <typename MatrixType, typename VecType>

if VecType were a typedef.


> having checked the following,
>   #define VecType PetscVecType
>   typedef char* PetscVecType;
> may already improve the situation substantially. Removing any
> preprocessor activity on the string/type 'VecType' would be the cleaner
> approach, though...
> Best regards,
> Karli

More information about the petsc-dev mailing list