What is different between Symbol() and _Symbol - page 2

 
void Func( const string& ) {}

void OnStart()
{
  Func(Symbol()); // ERROR: 'Symbol' - parameter passed as reference, variable expected
  Func(_Symbol);  // OK   
}
 
_Symbol is a system predefined variable an Symbol() is a function that return _Symbol variable content. So, for purists, _Symbol is more efficient in compilation time and generates smaller code. But, except for that, there is no difference.
Documentation on MQL5: Predefined Variables
Documentation on MQL5: Predefined Variables
  • www.mql5.com
For each executable mql5-program a set of predefined variables is supported, which reflect the state of the current price chart by the moment a mql5-program (Expert Advisor, script or custom indicator) is started. Values of predefined variables are set by the...
 


I am having these above errors in compiling this code. I am a beginner and wrote most wit search and type. If anyone can help me make it erro free, i will appreciate it

 
fxsaber #:
  Func(Symbol()); // ERROR: 'Symbol' - parameter passed as reference, variable expected
  Func(_Symbol);  // OK   

This is due to the bug of passing references of temporaries.

 
William Roeder #:

This is due to the bug of passing references of temporaries.

The code above is the answer to the question in the thread title.