Errors, bugs, questions - page 2271

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
A compilation error:
What is the fundamental difference between (1)(2) and (3)(4)?
If you declare classes (3)(4) outside of functions - no error occurs. If you declare inside a function, errors occur.
What can the following behavior be related to
compile indicator works correctly, compile again indicator does not work correctly. Does it work correctly in the tester?
Which indicator?
What does C++ produce here?
To make it work in MQL5, you need to have two different strings in the output, not the same one. But then the mechanism of signature forming should be absolutely different. If C++ gives the same result in print, the __FUNCSIG__ cost will drop dramatically.
Result: C++
void f<g1::A>( g1::A& )
void f<g2::A>( g2::A& )
As you can see the strings are different... the function signature is used
Result: C++
void f<g1::A>( g1::A& )
void f<g2::A>( g2::A& )
As you can see the strings are different... the function signature is used
MQL5 gives out.
void f<A>(A&)
I.e. there is no class signature inside the function. It will be supported someday.
And if the class is global, which line will C++ generate?
void f<::A>( ::A& )
void f<A>( A& )
MQL5 gives out
I.e. there is no class signature inside the function. It will be supported someday.
If obsolete C++ compilers do not support it, they already give an error on the first line (1) in the source code. That's why the question was posed in this way in the first place: why is there an error in one case and a normal error in the other?
We expected the same behavior in both cases: either an error or no error. And the error is not in the lack of support per se, but in the unequal behaviour under otherwise equal conditions (as in this example)
And if the class is global, which line does C++ produce?
void f<::A>( ::A& )
void f<A>( A& )
The second variant
If obsolete C++ compilers do not support this, they already give an error on the first line (1) in the source code. That's why the question was posed in this way in the first place: why is there an error in one case and a normal error in another?
We expected the same behavior in both cases: either an error or no error. And the error is not in the lack of support per se, but in unequal behavior, all else being equal (as in this example)
Well, it's easy to explain. The compiler goes from top to bottom through the code forming corresponding signatures as it goes along. The first signature is created without any problems. It comes to the second one and there is already such a signature. Here we have an error on the second line.
If you declare classes (3)(4) outside functions, no errors occur. If you declare inside a function - errors occur.
replace by
If you declare inside a function, no errors occur either... what is the fundamental difference?
So it's understandable. The compiler goes from top to bottom of the code, forming appropriate signatures as it goes along. It creates the first signature without any problems. It gets to the second one and it already has one. Thus, there is an error on the second line.
So why does it compile in MQL without errors?
Result: MQL C++
void f<A>() void f<g1::A>()
void f<A>() void f<g2::A>()
Why are the signatures created here without any interference?
So why does it compile in MQL without errors?
Result: MQL C++
void f<A>() void f<g1::A>()
void f<A>() void f<g2::A>()
Why are the signatures created here without any interference?
One is only created. Moreover, in f you cannot use T. Anyway, the situation is obvious to me.