[petsc-dev] Fwd: SACUDA - Cannot compile

Satish Balay balay at mcs.anl.gov
Wed Oct 27 17:38:18 CDT 2010


This change compiles for me.

Victor,

Perhaps you can check if this actually avoids namespace clash for your or not..

cd petsc-dev
patch -Np1 < vectype-def.patch

Satish

On Wed, 27 Oct 2010, Satish Balay wrote:

> Ok - perhaps we can simulate current behavior with:
> 
> typedef char* VecType;
> typedef const char* ConstVecType;
> 
> and use VecType/ConstVecType as needed in code?
> 
> Satish
> 
> On Wed, 27 Oct 2010, Barry Smith wrote:
> 
> > 
> >   Satish,
> > 
> >     We already had this fight and this change lost. Making this change means that one can never build a VecType on the fly, so all VecType must be declared at compile time which defeats the entire purpose of PETSc.
> > 
> >    I don't understand why "const" is scoped differently for a macro than for the typedef." but it seems to me an annoying feature of C.
> > 
> >    Barry
> > 
> > 
> > On Oct 27, 2010, at 5:08 PM, Satish Balay wrote:
> > 
> > > On Wed, 27 Oct 2010, Barry Smith wrote:
> > > 
> > >> 
> > >> On Oct 27, 2010, at 4:48 PM, Jed Brown wrote:
> > >> 
> > >>> On Wed, Oct 27, 2010 at 17:45, Barry Smith <bsmith at mcs.anl.gov> wrote:
> > >>> hmm, is there any reason we can't/shouldn't use a typedef for our VecType (and its many friends)?
> > >>> 
> > >>> I think the issue is because "const" is scoped differently for a macro than for the typedef.
> > >>> 
> > >>> typedef char *Foo;
> > >>> 
> > >>> now "const Foo" means "char *const" instead of "const char *".
> > >> 
> > >>  Damn, damn, damn, damn,
> > > 
> > > -#define VecType char*
> > > +typedef const char* VecType;
> > > 
> > > -EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetType(Vec, const VecType *);
> > > +EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetType(Vec, VecType *);
> > > 
> > > The above type of change [i.e 'const VecType' to 'VecType'] gets
> > > src/vec/vec/interface sources compiled..
> > > 
> > > Satish
> > 
> > 
> 
> 
-------------- next part --------------
diff -r 288cde16eb1f include/petscdm.h
--- a/include/petscdm.h	Wed Oct 27 17:18:57 2010 -0500
+++ b/include/petscdm.h	Wed Oct 27 17:32:40 2010 -0500
@@ -111,7 +111,7 @@
 EXTERN PetscErrorCode PETSCDM_DLLEXPORT    DMDACreate2d(MPI_Comm,DMDAPeriodicType,DMDAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],DM*);
 EXTERN PetscErrorCode PETSCDM_DLLEXPORT    DMDACreate3d(MPI_Comm,DMDAPeriodicType,DMDAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],DM*);
 EXTERN PetscErrorCode PETSCDM_DLLEXPORT DMSetOptionsPrefix(DM,const char []);
-EXTERN PetscErrorCode PETSCDM_DLLEXPORT DMSetVecType(DM,const VecType);
+EXTERN PetscErrorCode PETSCDM_DLLEXPORT DMSetVecType(DM,ConstVecType);
 
 EXTERN PetscErrorCode PETSCDM_DLLEXPORT    DMDAGlobalToNaturalBegin(DM,Vec,InsertMode,Vec);
 EXTERN PetscErrorCode PETSCDM_DLLEXPORT    DMDAGlobalToNaturalEnd(DM,Vec,InsertMode,Vec);
diff -r 288cde16eb1f include/petscvec.h
--- a/include/petscvec.h	Wed Oct 27 17:18:57 2010 -0500
+++ b/include/petscvec.h	Wed Oct 27 17:32:40 2010 -0500
@@ -95,7 +95,8 @@
 
 .seealso: VecSetType(), Vec
 E*/
-#define VecType char*
+typedef char* VecType;
+typedef const char* ConstVecType;
 #define VECSEQ         "seq"
 #define VECMPI         "mpi"
 #define VECSTANDARD    "standard"   /* seq on one process and mpi on several */
@@ -322,8 +323,8 @@
 /* Dynamic creation and loading functions */
 extern PetscFList VecList;
 extern PetscBool  VecRegisterAllCalled;
-EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetType(Vec, const VecType);
-EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetType(Vec, const VecType *);
+EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetType(Vec, ConstVecType);
+EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetType(Vec, ConstVecType *);
 EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegister(const char[],const char[],const char[],PetscErrorCode (*)(Vec));
 EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegisterAll(const char []);
 EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegisterDestroy(void);
diff -r 288cde16eb1f src/dm/interface/dm.c
--- a/src/dm/interface/dm.c	Wed Oct 27 17:18:57 2010 -0500
+++ b/src/dm/interface/dm.c	Wed Oct 27 17:32:40 2010 -0500
@@ -59,7 +59,7 @@
 
 .seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMDestroy(), DMDA, DMDAInterpolationType, VecType
 @*/
-PetscErrorCode PETSCDM_DLLEXPORT DMSetVecType(DM da,const VecType ctype)
+PetscErrorCode PETSCDM_DLLEXPORT DMSetVecType(DM da,ConstVecType ctype)
 {
   PetscErrorCode ierr;
 
diff -r 288cde16eb1f src/vec/vec/interface/vecreg.c
--- a/src/vec/vec/interface/vecreg.c	Wed Oct 27 17:18:57 2010 -0500
+++ b/src/vec/vec/interface/vecreg.c	Wed Oct 27 17:32:40 2010 -0500
@@ -30,7 +30,7 @@
 .keywords: vector, set, type
 .seealso: VecGetType(), VecCreate()
 @*/
-PetscErrorCode PETSCVEC_DLLEXPORT VecSetType(Vec vec, const VecType method)
+PetscErrorCode PETSCVEC_DLLEXPORT VecSetType(Vec vec, ConstVecType method)
 {
   PetscErrorCode (*r)(Vec);
   PetscBool      match;
@@ -74,7 +74,7 @@
 .keywords: vector, get, type, name
 .seealso: VecSetType(), VecCreate()
 @*/
-PetscErrorCode PETSCVEC_DLLEXPORT VecGetType(Vec vec, const VecType *type)
+PetscErrorCode PETSCVEC_DLLEXPORT VecGetType(Vec vec, ConstVecType *type)
 {
   PetscErrorCode ierr;
 
diff -r 288cde16eb1f src/vec/vec/interface/vector.c
--- a/src/vec/vec/interface/vector.c	Wed Oct 27 17:18:57 2010 -0500
+++ b/src/vec/vec/interface/vector.c	Wed Oct 27 17:32:40 2010 -0500
@@ -1027,7 +1027,7 @@
   const char     *prefix;
   PetscBool      flg;
   char           vtype[256];
-  const VecType  outtype=0;
+  ConstVecType  outtype=0;
 
   PetscFunctionBegin;
   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
@@ -1325,7 +1325,7 @@
 static PetscErrorCode VecSetTypeFromOptions_Private(Vec vec)
 {
   PetscBool      opt;
-  const VecType  defaultType;
+  ConstVecType  defaultType;
   char           typeName[256];
   PetscMPIInt    size;
   PetscErrorCode ierr;


More information about the petsc-dev mailing list