By the way, there seems to be an error in the mql preprocessor.
#define i ##nt ll;
expands to 'i nt ll;' and gives an error:
'i nt' - undeclared identifier t_t_t.mq4 50 1
Regarding the comments in the enumeration - supposedly they should be twitching up to the C preprocessor. So even if it was possible to cram a comment in, it would be unlikely to have an effect. In a good way, you should change the syntax (to _cmnt_, for example) and change the call sequence of the C preprocessor with the preprocessor that pulls the comments. Prospects for such reforms are unlikely, I think ))
The last method required to write the blanks manually for enum and the function that returns an array of values. I decided to figure it out and write it in such a way that it is no longer needed. However, it cannot be compiled in mql, there are no macros with variable number of arguments, but theoretically they can appear. Anyway, here's what I've got:
// Generated code for emum1 // enum enum1{ // q = 1, // e = 3, // t = 65, // z = 90, // }; // unsigned get_enum1_array(int *ar){ // int temp[] = { q, e, t, z, }; // if(ar != NULL) // for(unsigned i = 0; i < sizeof(temp) / sizeof(int); ++i){ // ar[i] = temp[i]; } // return sizeof(temp) / sizeof(int); // }
Article on this subject http://jhnet.co.uk/articles/cpp_magic. All in all, a lot of magic, of course. But the technique can be useful for a wide range of tasks referring to preprocessor code generation.
The C Pre-Processor (CPP) is the somewhat basic macro system used by the C programming language to implement features such as and which allow very simple text-substitutions to be carried out at compile time. In this article we abuse the humble to implement if-statements and iteration. Before we begin, a disclaimer: these tricks, while perfectly...
However it cannot be compiled in mql, there are no macros with variable number of arguments, but theoretically they can appear.
In MQL5 macros not only have a fixed number of arguments, but their number is limited to 8. So you can make an enum for only 3 values.
As for theoretical appearance, it will probably be faster to get an in-house function for enum parsing, as the developers have already promised to do something.
In MQL5 macros not only have a fixed number of arguments, but the number of arguments is limited to 8. So we can make an enum for only 3 values.
As for the theoretical appearance, it's probably faster to get an in-house function for enum parsing. The developers have already promised to come up with something.
No iterator to enumerate enum values is planned. Use previously proposed method of enumeration using array.
Ilyas: No iterator is planned for enumerator value enumeration. Use the previously suggested method of enumerating values using an array.
It turns out to be the same switch, but from the side. That is, two lists will need to be maintained in any case: the enumerator itself and the array (switch cases).
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
What about the normal names that are in the comments?
By the way, there seems to be an error in the mql preprocessor.
expands to 'i nt ll;' and gives an error:
'i nt' - undeclared identifier t_t_t.mq4 50 1
Regarding the comments in the enumeration - supposedly they should be twitching up to the C preprocessor. So even if it was possible to cram a comment in, it would be unlikely to have an effect. In a good way, you should change the syntax (to _cmnt_, for example) and change the call sequence of the C preprocessor with the preprocessor that pulls the comments. Prospects for such reforms are unlikely, I think ))
By the way, there seems to be an error in the mql preprocessor.
expands to 'i nt ll;' and gives an error:
Dynamic ENUM is for internal use, the settings window doesn't show these. Normal names/comments are not really needed
The last method required to write the blanks manually for enum and the function that returns an array of values. I decided to figure it out and write it in such a way that it is no longer needed. However, it cannot be compiled in mql, there are no macros with variable number of arguments, but theoretically they can appear. Anyway, here's what I've got:
Выхлоп printf:
----enum1-----
1
3
65
90
----enum2-----
100
-3
21
----enum3-----
871
213
226
// Generated code for emum1
// enum enum1{
// q = 1,
// e = 3,
// t = 65,
// z = 90,
// };
// unsigned get_enum1_array(int *ar){
// int temp[] = { q, e, t, z, };
// if(ar != NULL)
// for(unsigned i = 0; i < sizeof(temp) / sizeof(int); ++i){
// ar[i] = temp[i]; }
// return sizeof(temp) / sizeof(int);
// }
Article on this subject http://jhnet.co.uk/articles/cpp_magic. All in all, a lot of magic, of course. But the technique can be useful for a wide range of tasks referring to preprocessor code generation.
I read the thread with interest, all very cool with macros.
It's just not clear, why do we need all this dancing with enum? Can you give a practical example?
It's clear about TF, but what else?
However it cannot be compiled in mql, there are no macros with variable number of arguments, but theoretically they can appear.
In MQL5 macros not only have a fixed number of arguments, but their number is limited to 8. So you can make an enum for only 3 values.
As for theoretical appearance, it will probably be faster to get an in-house function for enum parsing, as the developers have already promised to do something.
In MQL5 macros not only have a fixed number of arguments, but the number of arguments is limited to 8. So we can make an enum for only 3 values.
As for the theoretical appearance, it's probably faster to get an in-house function for enum parsing. The developers have already promised to come up with something.
Use previously proposed method of enumeration using array.
No iterator is planned for enumerator value enumeration.
Use the previously suggested method of enumerating values using an array.