Errors, bugs, questions - page 2474

 
fxsaber:

How do you choose between using templates and void* ?

There is no special approach, it's just a matter of intuition

 
Unfortunately, at the moment function pointer types in MT4/MT5 are very limited and not practical due to some defects:
#(not fixed in MT5(build 2060))"Compilation error when using the same function signature repeatedly within typedef".
#(not fixed in MT5(build 2060))"When working with typedef, using a template function with explicit specialization does not generate code for that template function".


In view of the pending namespace implementation, please consider implementing support for this behavior as part of the defect fixes in the next C++:
//#include <iostream>

template<typename T>
class A{
public:
    typedef void (*callback)(T&);   //class namespace for function pointer type
    callback f_ptr;
    T data;
};

template<typename T>
class B{
public:
    typedef void (*callback)(T&);   //class namespace for function pointer type
    callback f_ptr;
};

template<typename T>
void func(T& value){
    ++value;
}


void OnStart(){
//int main(){
    A<int> a;
    B<int> b;
    
    a.f_ptr = func<int>;      // automatic code generation of templates functions
    b.f_ptr = a.f_ptr;        // assignment operation for function pointers with the same function signatures and different function pointer types.
    
    int x = 1;
    b.f_ptr(x);
    printf("%d\r\n", x);                  //2
    printf("%d\r\n", b.f_ptr == a.f_ptr); //1     // equal operation for function pointers with the same function signatures and different function pointer types.
}
 

Hi! Please pay attention to the topic

https://www.mql5.com/ru/forum/314275

In a nutshell, the tester calculates a margin that does not match the one set in the symbol settings
[bug] Неправильная Margin при тестировании на custom symbol
[bug] Неправильная Margin при тестировании на custom symbol
  • 2019.05.25
  • www.mql5.com
Привет! Создал кастомный символ с параметрами, скопированными из реального Si-3.19. См. скриншоты. Загрузил для него историю...
 

Forum on trading, automated trading systems and strategy testing

New version of MetaTrader 4 build 1170 platform

fxsaber, 2019.05.28 12:10

Is this a bug in the MT4 compiler?
#property strict

void Func( int &[] ) {}
void Func( int &[][2] ) {} // 'Func' - function already defined and has body

void OnStart()
{
  int Array1[];
  int Array2[][2];
  
  Func(Array1);
  Func(Array2); // 'Array2' - invalid array access
}


There is no problem with this in MT5. In MT4 there is no way to overload the function.

 

Slight mishap in MT 4 in MT 5 not checked...


 

Forum on trading, automated trading systems and strategy testing

New version of MetaTrader 4 build 1170 platform

fxsaber, 2019.05.28 14:24

Caught an unfamiliar difference between MT4 and MT5. Is this a bug in MT4?
#property strict

bool Print2( const string Str )
{
  Print(Str);
  
  return(true);
}

void Func()
{
  static bool b = Print2(__FUNCSIG__); // MT4 - вызывается, MT5 - нет.
}

void OnStart() {}
 
fxsaber:

Five has done a proper initialisation of the statics. On the first access.

Four didn't. And there's no telling when we will.

 

build 2062: Error 5305 when creating a custom symbol.

In 2060 everything is OK.

I remember in MT4 there was a command line key /skipupdate

Is there something similar in MT5? How can i disable updates?

 

fxsaber:

MT4 is called, MT5 is not.

You seem to be compiling with an old compiler, compile with a modern one (included in MT5) and everything will be fine.
 
Alexey Navoykov:
Looks like you're compiling with an old compiler. Compile with a modern one (coming with MT5) and everything will be fine.

Compiled through 1966. Tried 2062 in MT4 - works correctly. Thank you!

It's a pity there's no way to beat this.