Ios not available

Hi,

I am using ios::open_mode and its various values in a macro to open a file in write or append mode. This used to work in root 3.3/xx, but broke sometime later. I just downloaded the most recent verison of root 4.00, and it is still broken. In fact, I noticed that you changed the basic.C tutorial not to use ios::read anymore (i was pointed to this macro by searching the forum on ios::).

I guess this is not an urgent thing, but could you please look into it sometime?

The error message in root 4.00 is:

root [6] std::ios::out
Error: Ambiguous overload resolution (100,2) FILE: LINE:0
Calling : G__ateval(ios_base::open_mode);
Match rank: file line signature
ffffffff _string 58 int G__ateval(const string&);
1000001 _iostream 121 int G__ateval(const TString&);
10000 _iostream 117 int G__ateval(unsigned long);
10000 _iostream 116 int G__ateval(unsigned int);
10000 _iostream 115 int G__ateval(unsigned short);
10000 _iostream 114 int G__ateval(unsigned char);

  •  100 _iostream  113 int G__ateval(long);
    
  •  100 _iostream  112 int G__ateval(int);
    
    10000 _iostream 111 int G__ateval(short);
    10000 _iostream 110 int G__ateval(char);
    10000 _iostream 109 int G__ateval(bool);
    10000 _iostream 108 int G__ateval(float);
    10000 _iostream 107 int G__ateval(double);
    ffffffff _iostream 105 int G__ateval(const char*&);
    1000001 (compiled) 0 int G__ateval(long double);
    1000001 (compiled) 0 int G__ateval(unsigned long long);
    1000001 (compiled) 0 int G__ateval(long long);
    (const enum ios_base::open_mode)16

and

root [10] std::ios::open_mode
Error: Symbol open_mode is not defined in current scope FILE:(tmpfile) LINE:1
*** Interpreter error recovered ***
root [11] ios::openmode
Error: Symbol openmode is not defined in current scope FILE:(tmpfile) LINE:1
*** Interpreter error recovered ***

the context in which I was using it is:

void make_h_file(const Char_t *name,TH1 *hist,const Char_t mode=‘w’) {
ios::open_mode m_flag=ios::out|ios::trunc;
if (mode==‘a’)
m_flag=ios::out|ios::app;

ofstream fout(name,m_flag);

// etc etc
}

Let me quickly answer your question.

I do not remember precisely, but I think you need to use ios_base::in. In the latest standard, ios::read doesn’t exist. Probably, I deleted it.

About G__ateval errors, Thank you for reporting this problem. I am finding G__ateval() giving many problems, althought it is quite convenient. I’ll try to fix it.

3rd, when you want to see ios::opem_mode or openmode in root prompt, you need to use .class command because it is a typename. If you want to see what value is defined, .class ios or .class ios_base is the right command.

Thank you
Masa Goto

Hi Masa,

Thanks for your explanation. As you say, it works with ios_base. I guess I just had not expected it to change…

Marco.