OOP, templates and macros in mql5, subtleties and uses - page 24

 
Vict:

So it'll work, I guess:

it doesn't work like that

#import is expecting a filename

Vict:

Just don't get it - what are the candles burning for?

I don't want to make connection manager in dll, and in MT4 for some reason, if I call 2 times dll from 2 EAs then new dll copy is not created in memory (dll has static objects, wrapper over .Net - if I run one dll then it crashes, 2 different files without problems),

so i wanted to quickly - just copy mylib.dll file to mylib02.dll and everything works without problems.... but want to globally declare a macro substitution

 
Igor Makanu:
it doesn't work like this

And this looks like a bug/failure. Pay attention to the PS in last post

PS: if you still really want to, try name_dll (without the dot), maybe it will take off.

 
Vict:

And this looks like a bug/failure. Pay attention to the PS in the previous post

This is not the case with MT4

MT4 will see the dll itself only in runtime, and what I'm discussing with you - it's not allowed by the compiler itself, i.e. this is how the compiler will pass

#import "mylib.dll"
#import
#import "mylib"
#import

and if you write it that way:

#import 
"mylib.dll"   //'mylib.dll' - expressions are not allowed on a global scope
#import

i.e. there's a rigid syntax directive #import + some string in quotes - and it's all on one line

but i don't know why i can't replace #import "mylib.dll" by my combination through macro substitution

Vict:

PS: if you still really want to, try to give name_dll (without a dot), maybe it will take off.

I don't understand why I can't even build inludes with conditional compilation? - everything works very primitively in MQL .... although i hope i just don't understand it
 
Igor Makanu:

This is not the case with MT4

MT4 will see the dll itself only in runtime, and what I'm discussing with you - the compiler won't let it pass, i.e. this is how the compiler will pass

and if you write it that way:

i.e. there's a rigid syntax directive #import + some string in quotes - and it's all on one line

But who knows why I can't macro substitute #import "mylib.dll" for my combination

I don't understand why I can't even build inludes with conditional compilation? - everything works very primitively in MQL .... although i hope i just don't understand it

I don't know why it doesn't work for you, it works for me.

#define  DD "jkjk.dll"
#import  DD
void fn();
#import
Now just set different DD in different EAs ("lib_1.dll", "lib_2.dll").
 
Vict:

I don't know why it's not working for you, it's working for me

Now just set different DD in different EAs ("lib_1.dll", "lib_2.dll").

Sorry, forgot - my sources are passed through slang preprocessor, in µl - yes, it doesn't work.

 
Vict:

Sorry, forgot - my sources are passed through slang preprocessor, in µl - yes, doesn't work.

In general, I have taken MQL, so it will work as intended

#ifdef  USE_DLL_NUMBER
   #ifdef  USE_DLL_NUMBER02 
      #import "mylib2.dll"
   #endif 
#else 
#import "mylib.dll"   
#endif

I declare 2 macro substitutions in the main code

#define  USE_DLL_NUMBER

#define  USE_DLL_NUMBER02 

... would cut it down to one macro USE_DLL_NUMBER02 - is in general something similar to what would suit me - I want to be able to write USE_DLL_NUMBER03 , USE_DLL_NUMBER04 - in the future if the need arises

 
Igor Makanu:

... reduce it to a single macro USE_DLL_NUMBER02 - is in general something similar to what would suit me - I want to be able to write USE_DLL_NUMBER03 , USE_DLL_NUMBER04 - in the future if the want

in general, with the help of brute force, it was possible to solve this problem

#ifdef  USE_DLL_NUMBER01 
#define  USE_DLL_NUMBER 
#endif
#ifdef  USE_DLL_NUMBER02  
#define  USE_DLL_NUMBER 
#endif
#ifdef  USE_DLL_NUMBER03 
#define  USE_DLL_NUMBER 
#endif
#ifdef  USE_DLL_NUMBER04 
#define  USE_DLL_NUMBER 
#endif
#ifdef  USE_DLL_NUMBER05 
#define  USE_DLL_NUMBER 
#endif
 

Why doesn't mql4 implement a #if macro that works by value, you could create selective objects like

#define  Znah 0
#define  PrmI int    Peremen=6;
#define  PrmD double Peremen=3.345;

#if  Znah//если больше 0 то появится переменная int Peremen
   PrmI
#else
    PrmD//иначе появится переменная double Peremen
#endif
As a result, the whole subsequent program can be corrected with the right type
 
I have never encountered an expression returning false.
ORDER_TIME_DONE_MSC == DEAL_TIME_MSC

Therefore, it is difficult to keep statistics on order execution time based on trading history.

If we can still match the value ofORDER_TIME_SETUP_MSC for market orders, it is meaningless for orders.

 
It's most likely an obsolete one. The const modifier does not guarantee that the object will not be changed.
struct A
{
  int i;

  void f( const A &Value )  
  {
    Print(Value.i); // 0
    
    this.i = Value.i + 1;
    
    Print(Value.i); // 1
  }
};

void OnStart()
{
  A a;
  
  a.f(a);
}


Some compilers probably issue warnings in these situations.