Re: [CINT] RE: [ROOT] "std::string" in Root?

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Fri Sep 13 2002 - 09:40:48 MEST


Hello Philippe and Ole,

Cint has a flag of ignoring std namespace. std namespace is ignored
(means std::xxx are in global namespace) by default.  Cint handles
std:: only when -Y0 flag is given to both makecint/rootcint and cint/root.

>From the symptom,  rootcint does not get -Y0  but root is started with -Y0.
In your ROOT run-time, there are following classes.

     class std::string
     namespace my
     class my::MyClass

And it tries to define a member function 'my::MyClass::f(string)'. Note
that string is loaded as std::string, so string can not be found. Cint
generates a new class entry in namespace my.   So,

    class my::string

is added as undefined class entity.

Solution to this situation is to give -Y0 flag for rootcint too.

Thank you
Masaharu Goto


----- Original Message -----
From: "Philippe Canal" <pcanal@fnal.gov>
To: <roottalk@pcroot.cern.ch>; "Cint" <cint@pcroot.cern.ch>
Sent: Friday, September 13, 2002 4:46 AM
Subject: [CINT] RE: [ROOT] "std::string" in Root?


> Hi Ole,
>
> I am not exactly sure of the circumstances of your failure.  In the
example below, I was successful 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 candles 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