Errors, bugs, questions - page 2895

 
A100:
A compilation error:

used to work, but at the beginning of the year they broke the function pointers, it seems your code should still work in MT4

it will work:

typedef void (*fn)();
void f() {}
fn g() { return f; }
void OnStart()
{
    fn func = g();
    func();
}

i.e. now you have to use a temporary variable ( now you can't even use an array of pointers!!!! )

A100:

There is some contradiction here because

What is thedifference in principle?

One of the admins wrote a long time ago how the parsing is done, first static variables, then globally described, then the body of the function, parsing from top to bottom in the text

... but that's not accurate ;)

 
Igor Makanu:

i.e. now you have to use a temporary variable ( now you can't even use the pointer array!!!! )

That's why I wrote it, so that Developers could do without the temporary

 
A100:

That's why I wrote, so that if possible, the Developers could do it without the temporary

@fxsaber wrote as soon as they found it, probably a year has passed, well, maybe you will be heard
 
Igor Makanu:

i.e. now you have to use a temporary variable ( now you can't even use the pointer array!!!! )

Do you have an example to prove that you can't?

 
A100:

Do you have an example to prove that you can't?

wrote an example:

typedef void (*fn)();
void f() {}
fn g() { return f; }
void OnStart()
{
//   fn ptr[10];                                                 //possible use of uninitialized variable 'ptr'
   fn ptr[10] = {0};                                             // OK
   for(int i = ArraySize(ptr) - 1; i >= 0; i--) ptr[i] = g();
   
//   for(int i = ArraySize(ptr) - 1; i >= 0; i--) ptr[i]();     //')' - expression expected
   
   for(int i = ArraySize(ptr) - 1; i >= 0; i--)                  // OK
   {
      fn func = ptr[i];
      func();
   }
}

I was surprised, for some reason it generates a warning fn ptr[10]; //possible use of uninitialized variable 'ptr'

now I need to figure out how to initialize pointers to functions


used to be possible in MQL5: ptr[i]();
 
Igor Makanu:

You could use in MQL5: ptr[i]() before;

Yes... I remember

Forum on trading, automated trading systems & strategy testing

Bugs, bugs, questions

A100, 2020.07.23 02:40

Error during compilation

typedef void (*fn)();
void OnStart()
{
        fn ff[ 1 ];
        ff[ 0 ](); //Error:: ')' - expression expected
} 

I had a bug in last year's build, it all compiled and worked fine.

Forum for trading, automated trading systems & strategy testing

Bugs, bugs, questions

A100, 2020.07.23 16:31

I drew build 2085x32 from old stock - it all compiles well - you can try it yourself

 
It's a compilation error:
class EventChartCustom {
      EventChartCustom() {}
};
bool f()
{
    return (EventChartCustom( 0, 0, 0, 0, NULL ) ? true : false); //(1) Error: 'EventChartCustom' - wrong parameters count
}
but that's OK:
bool f()
{
    if (    EventChartCustom( 0, 0, 0, 0, NULL ) ) //(2) нормально
        return (true);
    else
        return (false);
}

What is the fundamental difference?

 
A compilation error:
class A {
      A() {}
};
void A() {} //(1) Error: 'A' - identifier already used
but that's fine:
void A() {} //(2) нормально
class A {
      A() {}
};

What is the fundamental difference?

 
Rule of thumb from the Marketplace.
В Продуктах запрещен вызов любых DLL-библиотек, включая системные библиотеки Microsoft Windows.
Does the Market product have the right to extend its functionality if the user is allowed to use the DLL?
 

Couldn't find any statistics on the Marketplace. So a question for sellers of cross-platform products.

Do MT5 versions really sell better than MT4?