Errors, bugs, questions - page 1922

 

Compilation error.

#define  MACRO( x )      ((x) + 2)
struct A {
        A( int, int ) {}
};
template<typename T>
struct B {
        static A a;
};
template<typename T>
A B::a( MACRO(1), 2 ); //error: '(' - declaration without type
And withouttemplate<typename T> it's fine... what's the difference?
 
A100:

Compilation error

And withouttemplate<typename T> - ok... what's the difference?

It's the extra brackets in the macro.

struct A {
        A(int) {}
};

template<typename T>
struct B {
        static A a;
};
template<typename T>
A B::a((0));

If you remove them, it will compile.

 
fxsaber:

It's the extra brackets in the macro.

If you remove them, it will compile.

If you remove template<typename T>, it will also compile (even with brackets)
 
A100:

The .log files %AppData%\MetaQuotes\Terminal\...\MQL5\Logs\YYYYMMDD.log are not updated promptly

The update only happens: after restarting the terminal or after selecting View menu. If you don't restart or click Preview, the corresponding file will be empty.

It used to work well (even the YYYYYMMDD.log file opened in MetaEditor was automatically updated in a few seconds after displaying rows in Experts tab) and no extra non-obvious actions had to be performed

IMHO, it's always been like that if log size is small (there was info somewhere on forum about size, at which cache dumping starts). I always had to invoke the context menu to initialise the flush to disk.

 
Stanislav Korotky:

IMHO, this has always been the case if the log size is small (there was info somewhere on the forum about the size at which the cache reset starts). I always had to call the context menu to initialise the flush to disk.

I don't quite understand the point of your IMHO. Take build <= 1596 (32bit) and check (outputs to .log file immediately [5-10 seconds] even one line). I checked it a minute ago.

[which cache? which always? there was something about something somewhere!?!]

it's about the Experts tab and MQL5\Logs\ folder

 
A100:
If you remove template<typename T> it will compile too (even with parentheses)

Well, it's a phrase from the "if you remove everything, it will compile" category.

I was speaking about the causes of the error exactly with template. The reason is incorrect compiler's behavior when parsing a template construct in the situation with additional parentheses. Anyone who has implemented the templates can immediately see where the problem is and why it occurs.

 

Hi guys, I have a task to display two indicators iMACD_1 colour, signal line and iMACD_2 in a separate window, here is part of the code:

I have made indexing

   SetIndexBuffer(0,MACDBuffer_1,INDICATOR_DATA);
   SetIndexBuffer(1,buffer_color_histogram,INDICATOR_COLOR_INDEX);
   SetIndexBuffer(2,Signal_Line,INDICATOR_DATA);
   SetIndexBuffer(3,MACDBuffer_2,INDICATOR_DATA);

Got pointers to indicators

 handle_1=iMACD(name,period,fast_ema_period,slow_ema_period,signal_period,applied_price); 
 handle_2=iMACD(name_,period_,fast_ema_period_,slow_ema_period_,signal_period_,applied_price_);

(And then wonders)))

Theoretically it should work to display indicators

      if(CopyBuffer(handle_1,0,0,values_to_copy,MACDBuffer_1)<0)return(0);
      if(CopyBuffer(handle_1,1,0,values_to_copy,Signal_Line)<0) return(0);
      if(CopyBuffer(handle_2,3,0,values_to_copy,MACDBuffer_2)<0) return(0);

It doesn't work!

But it works like this

      if(CopyBuffer(handle_1,0,0,values_to_copy,MACDBuffer_1)<0)return(0);
      if(CopyBuffer(handle_1,1,0,values_to_copy,Signal_Line)<0) return(0);
      if(CopyBuffer(handle_2,0,0,values_to_copy,MACDBuffer_2)<0) return(0);

It works, I can not figure out what is the problem with the numbers of indicator buffers. Thanks in advance !!!

 

Compile error.

template<typename T>
struct A {
        static int a1;
        static int a2;
};
template<typename T>
int A::a1;
template<typename T>
int A::a2;
struct B : A<int> {
        void f1() { Print( A<int>::a1 ); } //unresolved static variable 'A<int>::a1'
        void f2() { Print(         a2 ); } //unresolved static variable 'B::a2'
};

And withouttemplate<typename T> - fine

 
vitrix:

Hi guys, I have a task to display two indicators iMACD_1 colour, signal line and iMACD_2 in a separate window, here is part of the code:

I have made indexing

Got pointers to indicators

(And then wonders)))

Theoretically it should work to display indicators

It doesn't work!

But it works like this

It works, I can not figure out what is the problem with the numbers of indicator buffers. Thanks in advance !!!


Please next time remember how toinsert the code in the post(your post I corrected).

Second: the iMACD indicator has only two buffers: "0" - MAIN_LINE, "1" - SIGNAL_LINE. So, to get indicator values will look like this:

   CopyBuffer(handle_iMACD,MAIN_LINE или SIGNAL_LINE,index - номер буфера с которого начинаем копирование,values_to_copy,buffer)
 
A100:

Compile error.

And withouttemplate<typename T> - fine

template<typename T>
struct A {
        static int a1;
        static int a2;
};
template<typename T>
int A::a1 = 0;
template<typename T>
int A::a2 = 0;
struct B : A<int> {
        void f1() { Print( A<int>::a1 ); } //unresolved static variable 'A<int>::a1'
        void f2() { Print(         a2 ); } //unresolved static variable 'B::a2'
};
Reason: