Hi Ashley, The Form and Printf functions have the following signature: char *Form(const char *fmt, ...); // format in circular buffer void Printf(const char *fmt, ...); // format and print if you compile your test program below, you will get a compiler message; warning: cannot pass objects of type `TString' through `...' #include <iostream.h> #include "TObject.h" void junk() { //----- Prints bob smith cout << Form("%s %s", "bob", "smith") << endl; //----- Only prints bob cout << Form("%s %s", TString("bob"), TString("smith")) << endl; //----- Prints bob smith Printf("%s %s", "bob", "smith"); //----- Only prints bob Printf("%s %s", TString("bob"), TString("smith")); } root > .x junk.C produces your output root > .x junk.C++ gives junk.C: In function `void junk()': junk.C:8: warning: cannot pass objects of type `TString' through `...' junk.C:8: warning: cannot pass objects of type `TString' through `...' junk.C:14: warning: cannot pass objects of type `TString' through `...' junk.C:14: warning: cannot pass objects of type `TString' through `...' bob smith LÅ dÅu bob smith |Å ?Åu Rene Brun Ashley Cambrell wrote: > > Hi All, > > This may be my own stupidity but why does this happen: > > * Version 3.03/04 2 May 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.35, Mar 25 2002 > Type ? for help. Commands must be C++ statements. > Enclose multiple statements between { }. > > //----- Prints bob smith > root [0] cout << Form("%s %s", "bob", "smith") << endl; <----- Prints > bob smith > bob smith > > //----- Only prints bob > root [1] cout << Form("%s %s", TString("bob"), TString("smith")) << endl; > bob > > //----- Prints bob smith > root [2] Printf("%s %s\n", "bob", "smith"); > bob smith > > //----- Only prints bob > root [3] Printf("%s %s\n", TString("bob"), TString("smith")); <----- > Only prints bob > bob > > root [4] > > I was encoutering this whilst creating sql strings from TString > variables (ie TString sql = Form("SELECT * FROM %s WHERE blah = '%s", > tstring_var1, tstring_var2); ) > > Is there something I'm missing? > > Thanks :-) > > Ashley Cambrell
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:52 MET