[SOLVED] extern int & int array_tmp[]={a,b,c};

 

Hi,

I have a probleme with comit extern int value in an array.

extern int a = 1;
extern int b = 2;
extern int c = 3;

int array_tmp[]={a,b,c};

When i compile, i have theses errors:

a - expression on gobal scope not allowed
b - expression on gobal scope not allowed
c - expression on gobal scope not allowed

Any idea ?

Regards

 
sharteel:

I have a probleme with comit extern int value in an array.

I got surprised by this myself recently. Arrays in MQ4 have to be initialised with constant values. What you're trying works in C but not in MQ4 (or MQ5). See https://docs.mql4.com/basis/variables/initialization - the last sentence on that page.

 

Hi,

i have found a solution:

extern int a = 1;
extern int b = 2;
extern int c = 3;

int array_tmp[]={0,0,0};


int init()
{

   array_tmp[0]=a;
   array_tmp[1]=b;   
   array_tmp[2]=c;   
}
Tx.