Errors, bugs, questions - page 2867

 
A100:
#define  TMP VALUE      // TMP = 10 VALUE

Got it, interpreted it differently here.

It's not a constant, but a macro, after all.

Thank you.
 
fxsaber:

So identical in action to MACRO and MACRO2.

For the end user, yes, one macro with two parameters is used

 
To the question about useful and harmful warnings:
#ifdef __cplusplus
class A {
    A( int  , int y ) :         //(1)
                        x( x ), //(2) warning: 'A::x' is initialized with itself
                        y( y )  //(3)
                    {}
    int x, y;
};
#endif

What does a smart Shell C++ compiler do? Right! Where there is an obvious misprint and in line (1) - missing 'x'

    A( int x, int y ) :

- it generates the warning: 'A::x' is initialized with itself. And it does not show anything in those places where it is OK!

And what does the MQL compiler do?

#ifdef __MQL__
class A {
    A( int  , int y ) :         //(1) warning: declaration of 'y' hides member
                        x( x ), //(2) нормально
                        y( y )  //(3)
                    {}
    int x, y;
};
#endif

It is silent when it needs it and there is an obvious misprint, but when it doesn't need it and everything is ok, it warns: declaration of 'y' hides member

Why is it the other way round?
 

2632

When paused in the visual test, it is not possible to browse (rewind/forward) the chart using either the drag and drop mouse or the arrow keys.

 

I see the topic of macros has taken off, I have some questions too

Why int and uint are used for C and D?
Where should long and ulong be substituted
or maybe the compiler is so clever that it senses the 280 size and optimizes it?

#define  A 280    // int
#define  B 280 U   // unsigned int
#define  C 280L   // long
#define  D 280LU  // unsigned long
#define  K 28.0   // double

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   Print(typename(A));
   Print(typename(B));
   Print(typename(C));
   Print(typename(D));   
   Print(typename(K));
}
2020.10.07 01:57:47.788 TestScript (EURUSD,M1)  int
2020.10.07 01:57:47.788 TestScript (EURUSD,M1)  uint
2020.10.07 01:57:47.788 TestScript (EURUSD,M1)  int
2020.10.07 01:57:47.788 TestScript (EURUSD,M1)  uint
2020.10.07 01:57:47.788 TestScript (EURUSD,M1)  double


The second question.
Why is there a compilation error for float?

#define  L 28.0 F  // float

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   Print(typename(L));
}
'TestScript.mq5'                TestScript.mq5  1       1
'F' - undeclared identifier     TestScript.mq5  36      19
'F' - some operator expected    TestScript.mq5  36      19
2 errors, 0 warnings                            3       1


The third question.

#define  E '\n'         // char
#define F B'111111111' // int
#define  J ""           // string

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   Print(typename(E));
   Print(typename(F));
   Print(typename(J));
}
2020.10.07 04:55:00.406 TestScript (EURUSD,M1)  ushort
2020.10.07 05:41:01.204	TestScript (EURUSD,M1)	uint
2020.10.07 04:55:00.406 TestScript (EURUSD,M1)  string
 
Roman:

I see the topic of macros has taken off, I have some questions too

Why int and uint are used for C and D ?
Where should long and ulong be substituted
or maybe the compiler is so clever that it senses the 280 size and optimizes it?


The second question.
Why is there a compilation error for float?


The third question.

1. L is long, but c++. Try LL
2. f
3 '\n' is char
 
Vladimir Simakov:
1. L is long, but c++. Try LL.
2. f
3 '\n' is char.

Yes. It works.
But the character type '+' shows ushort
Fits as a string size of 2 bytes

#define A 280          // int
#define B 280 U         // unsigned int
#define C 280 LL        // long
#define D 280 LLU       // unsigned long
#define E 28.0         // double
#define F 28.0 f        // float
#define J '+'          // char
#define K B'111111111' // int

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   Print(typename(A));
   Print(typename(B));
   Print(typename(C));
   Print(typename(D));   
   Print(typename(E));
   Print(typename(F));
   Print(typename(J));
   Print(typename(K));
}
2020.10.07 07:01:07.127 TestScript (EURUSD,M1)  int
2020.10.07 07:01:07.127 TestScript (EURUSD,M1)  uint
2020.10.07 07:01:07.127 TestScript (EURUSD,M1)  long
2020.10.07 07:01:07.127 TestScript (EURUSD,M1)  ulong
2020.10.07 07:01:07.127 TestScript (EURUSD,M1)  double
2020.10.07 07:01:07.127 TestScript (EURUSD,M1)  float
2020.10.07 07:01:07.127 TestScript (EURUSD,M1)  ushort
2020.10.07 07:01:07.127 TestScript (EURUSD,M1)  uint
 
Roman:

Yes. It worked.
But the character type '+' shows ushort
It sets it as a string size of 2 bytes

Why would it do that?

Is it a bug or a bug or something?

 
Vladimir Simakov:

Why is it like that?

Is it a flaw or a bug or something?

I don't know.
Maybe it's the Unicode?

 
Roman:

Who knows.
Maybe it's the Unicode?

No, the logic of the developers is understandable, but for me, I'd rather specify u'y' explicitly when and if I need it
Reason: