RE: [ROOT] including libraries, specifically <string>

From: Philippe Canal (pcanal@fnal.gov)
Date: Mon Apr 21 2003 - 16:56:08 MEST


Hi Justin,

The treatment of string from the CINT command is still dependent of which
ROOT build (how it was built) you use.  In most case, unless the build you
use has built the cintdlls, doing #include <string> actually pulls in an
interpreted version of the string.  This interpreted version of the string
is not compatible with the compiled version of string and thus will lead to
all kinds of trouble (unless you can make sure that the interpreted string
is never ever passed to compile code).

So to fix your problem you need to make sure that the cintdlls are built.

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Justin Findlay
Sent: Monday, April 14, 2003 4:22 PM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] including libraries, specifically <string>


Hi,

I have encountered a few scripting vexations probably having to do with
cint.  The first one is this.  It's nice to have a header filled with of
useful "TString" and "TCut" definitions that multiple script files can
refer to.

{
#include <string>
#include "/home/.../MyDefinitions.h"

using namespace std;
...

This will always return a segmentation fault, but if I switch the loading
order it will not.

{
#include "/home/.../MyDefinitions.h"
#include <string>

using namespace std;
...


When I include the <string> header from the standard namespace and then
issue a call to create a file object, interactive root quits without
interface or complaint as if the '.q' command had also been issued.

TFile * file = new TFile( my_file_path.c_str(), "read" );
  or
TFile * file = new TFile( "/home/.../my_file.root", "read" );

Excluding the <string> include statement, cint will not close when a TFile
declaration statement is executed, but then I can't use strings, assuming
that "string" offers functionality above that of "TString".  Perhaps the
<string> library is loaded already by cint.


It would be nice if there were a "TSstream" class that had all of the
"sstream" stream methods defined for "TString" class objects.  As it is I
have tried to use "sstream" stream methods for "std::string" objects and
cint tells me that "sstream" operators are not defined for "std::string"
objects.


Justin



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET