[petsc-users] Putting petsc in a namespace
Florian Lindner
mailinglists at xgm.de
Fri Sep 5 08:20:04 CDT 2014
Hello,
This may be rather a C/C++ question, but ...
I encapsulate some petsc functions into c++ classes. Since I don't want
to pull all petsc symbols into the global namespace for anyone using my
classes I try to put petsc into it's own namespace:
Header petsc.h:
namespace petsc {
#include "petscmat.h"
}
class Vector {
petsc::Vec vector;
}
Implementation petsc.cpp:
#include "petsc.h"
namespace petsc {
#include "petscviewer.h"
}
using namespace petsc;
User:
#include "petsc.h"
#include <petscksp.h> // if the user wants he can import parts of petsc
of course
But this gives a massive amount of error messsages like:
mpic++ -o petsc.o -c -O0 -g3 -Wall
-I/home/florian/software/petsc/include
-I/home/florian/software/petsc/arch-linux2-c-debug/include petsc.cpp
mpic++ -o prbf.o -c -O0 -g3 -Wall -I/home/florian/software/petsc/include
-I/home/florian/software/petsc/arch-linux2-c-debug/include prbf.cpp
In file included from
/home/florian/software/petsc/include/petscksp.h:6:0,
from prbf.cpp:9:
/home/florian/software/petsc/include/petscpc.h:9:14: error:
'PetscErrorCode' does not name a type
PETSC_EXTERN PetscErrorCode PCInitializePackage(void);
Is there a way to achieve what I want?
Thanks,
Florian
More information about the petsc-users
mailing list