Martin Bittencourt: So the compiler is saying that dtS may be used uninitialized, but that can't be the case: inside the for loop, at least one call to TimeToStruct2100 is going to happen
You passed an uninitialized variable to TimeToStruct. The compiler doesn't know that the function initializes the struct, not uses it. Initialize it: MqlDateTime dtS={0};
Hi! Thanks for the reply!
Well, that would explain the problem partially. My question is: in that case, why the compiler doesn't complain about the previous structure, currDTS, since it's also initialized whitin the same function?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi!
Since one of the latest versions (I won't be able to remember which, but I'm talking about last 1 month or so), I started to get the error "possible use of unitialized variable" in a code where that doesn't make sense (AFAICS):
The code is as follows:
So the compiler is saying that dtS may be used uninitialized, but that can't be the case: inside the for loop, at least one call to TimeToStruct2100 is going to happen (since 0 will always be < 290) where the structure will receive data:
Am I missing something or is the compiler really getting a false positive? In any case, the problem is easy to fix:
But I suppose MetaQuotes should be informed of the issue in case there is actually a bug, so here I am. Any thoughts?