Dear Wangtielei, First I would like to point out to you that ginac-devel@ginac.de is not the right list for questions like this. Better use ginac-list@ginac.de for this. On Thu, 6 Jul 2006, [gb2312] wangtielei(������) wrote:
#include <ginac/ginac.h> using namespace std;
It is generally considered bad to use "using" in a header file. The reason is that everybody using your header will get everything that is in the std-namespace for free and they may not want it because it may cause conflicting names.
namespace GiNaC {
I'm not sure what generally the opinions are on putting your own functions inside the namespace of a library. I never do that.
/* a test function*/ DECLARE_FUNCTION_2P(myfcn) } #endif
Delete the #endif. There is no corresponding #if. Better yet, use include guards for the header file.
and the source file <xxx.cxx> #include "xxx.h" #include "ginac.h"
This should be <ginac/ginac.h>. Or just omit the entire line as ginac.h is already included via xxx.h.
namespace GiNaC { REGISTER_FUNCTION(myfcn, dummy()) }
Now you also need test program that uses your new function. An example would be (put this in a file test.cxx): #include "xxx.h" using namespace std; using namespace GiNaC; int main() { ex f = myfcn(1,2); cout << f << endl; return 0; } Both files are compiled using g++ -c `ginac-config --cppflags` xxx.cxx g++ -c `ginac-config --cppflags` test.cxx and then linked using g++ -o test `ginac-config --libs` test.cxx xxx.cxx Actually, usually one would control the process of compiling and linking using a tool like make. Now typing ./test gives the output: myfcn(1,2) Good luck! Chris