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
uchar - Unsigned Character, why would you use this for a loop ? it doesn't make sense to me . . . use an int. You will be working with ulongs, that is what a new datetime is . . . and when you typecast without thinking about it in future you will get warned . . . deal with the warning or ignore it. Don't just hope for the best though, do as you are doing now, learn and understand
The stuff you posted from stackoverflow makes sense to me, I think it is good advice.
uchar was just an example as my question was related to the use of small variable types. uchar is a 1 byte positive value from 0 to 255 so for a loop 0 to 100 you could use the 1 byte uchar.
If you need to save a value returned from a function and the function in question returns a uchar then use a uchar variable to save the returned value . . . with the original mql4 this was a non issue, it will more of an issue with the new mql4.
When I asked the question I didnt know why I would want to that is why I asked the question lol...
I didnt know if an 8 bit variable type would process faster than a 32 bit or if it would be slower or just the same, I didnt know if an 8 bit value would use less RAM or less disk space. seeing as we now have those small variable types available to us I was just interested to know the pros and cons of using them when they would fit the requirements of the code block, vs just sticking with 32 bit integers across the board.
I thought maybe a 32 bit OS could process four 8bit values at the same time but I didnt know. Apparently not. This explains why a 64 bit OS is not really much faster than a 32 bit except for the fact it can access more RAM. I had often wondered about that.
I have a question, which I have not found solution for.
How to use void& ? I mean, if I need to send any pointer to a DLL. In the help file there are functions, which use this void type, but if I place it anywhere in the source, it won't compile. I tried to use template as a workaround, but template is prohibited within #import statement.
I managed construction for single types, but I am not able to implement passing void& array pointer to the DLL, unless I specify the explicit type.
Is there any limitation for passing array of structures to a DLL?
Suppose MT4Structure is a simple structure.
Having imported the kernel32.dll, a single structure works just fine:
but I am not able to get into work accepting the array of structures. The compiler won't compile with MT4Structure&[] if sent as a parameter to this declaration:
Is there any limitation for passing array of structures to a DLL?
I can't see a problem with something like this:
It works as expected (provided that you allow for different default structure-alignment in MT4 and the DLL).
(BTW, I'm not actually sure what the internal representation of a MQL4 bool now is, but I'd prefer to declare Win32 functions as returning int. Win32 functions return a BOOL rather than a C++ bool. A BOOL is a Windows macro for a 4-byte integer, whose value is 1/0, whereas a C++ bool is a single byte. If you tell MT4 to expect a single byte of return-value from functions when they are actually returning four bytes then you could - though it's very unlikely - end up with stack corruption.)
How to use void& ? I mean, if I need to send any pointer to a DLL.
I'm not quite sure what your question is. For example, the documentation of the Win32 API uses void* to mean "this accepts any type of pointer to anything; the Win32 function doesn't care what your block of memory is".
I'm not quite sure what your question is. For example, the documentation of the Win32 API uses void* to mean "this accepts any type of pointer to anything; the Win32 function doesn't care what your block of memory is".
Exactly. But it seems it is not quite possible with the MQL4, and using a template is not allowed within #import block. So using additional structure with winapi turns to manual update of the #import declarations every time a new type is needed. Which is rather uncomfortable for me, since my intention was managing the imports in one place.
Exactly. But it seems it is not quite possible with the MQL4, and using a template is not allowed within #import block. So using additional structure with winapi turns to manual update of the #import declarations every time a new type is needed. Which is rather uncomfortable for me.