Hi Ole, I am not exactly sure of the circunstances of your failure. In the example below, I was succesfull in making it work (at least with the version at the head of the CVS repository). However, there IS a known limitation that you might be encountering. Since you are using a compiled function (or method here) which expects a std::string, you need to make sure that the std::string used at the ROOT prompt is __compiled__. On most platform in the default mode, there is no dictionary for std::string provided. This means that you have to provide one by yourself, either by compiling the cintdlls or either generating it (as I did in the example below). If you do have a dictionary for std::string and you still have a problem, please send us a more detailed bug report (including actual commands tried and their faulty result and/or error messages as well as the linkdef you used). Cheers, Philippe. PS. I tried: rootcint -f dict.cc -c MyClass.h MyClassLinkDef.h && g++ --shared -o libst.so dict.cc `root-config --cflags` && root.exe ******************************************* * * * W E L C O M E to R O O T * * * * Version 3.03/08 12 September 2002 * * * * You are welcome to visit our Web site * * http://root.cern.ch * * * ******************************************* Compiled for linux with thread support. CINT/ROOT C/C++ Interpreter version 5.15.56, Sep 4 2002 Type ? for help. Commands must be C++ statements. Enclose multiple statements between { }. root [0] .L libst.so root [1] string s("this is an std string") root [2] my::MyClass m root [3] m.GetMe(s) this is an std string (int)0 With the files: <MyClassLinkDef.h> #ifdef __CINT__ #pragma link off all classes; #pragma link off all functions; #pragma link off all globals; #pragma link C++ namespace my; #pragma link C++ class my::MyClass; #pragma link C++ class std::string; #endif <\MyClassLinkDef.h> <MyClass.h> #include <string> #include <Rtypes.h> namespace my { class MyClass { public: int GetMe(std::string s) { fprintf(stderr,"%s\n",s.c_str()); return 0;}; ClassDef(MyClass, 1) }; } // rootcint -f dict.cc -c MyClass.h MyClassLinkDef.h // g++ --shared -o libst.so dict.cc `root-config --cflags` <\MyClass.h> ---------- Forwarded message ---------- Date: Wed, 11 Sep 2002 09:36:39 +0200 From: Ole Streicher <ole@ifh.de> To: roottalk <roottalk@pcroot.cern.ch> Subject: [ROOT] "std::string" in Root? Hello! I already asked this, but the mail seems to be lost in space... When I compile the class definition #include <string> #include <RTypes.h> namespace my { class MyClass { public: int GetMe(std::string); ClassDef(MyClass, 1) }; } I cannot use it from within root. It always tries to use "my::string" as the parameter definition of GetMe, and thus I cannot call GetMe with a string argument. So, my question is how it is possible to use strings within root? Ole
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:09 MET