Help me solve this problem. There is a macro and I want to add code inside it to return the result.
#define FOR3(a,b,c,loop) {for(int i=0; i<a; i++)\
for(int j=0; j<b; j++)\
for(int k=0; k<c; k++)\
{loop;}/*код хочу дописать в этом месте и вернуть результат но эта штука работает только как void*/}
Is it possible to add code in the given place so that I could return the result from the macro? You can add the code; I tried it but if you write return, the effect is not expected. I saw this example
Help me solve this problem. There is a macro and I want to add code inside it to return the result.
Is it possible to add code in the given place so that I could return the result from the macro? You can add the code; I tried it but if you write return, the effect is not expected. I saw this example
here in the topic where return works.
Call a function in which you pass a pointer to another function (loop body, for example)
int for3(int a, int b, int c, void(*loop)()) {
for(int i=0; i<a; i++)
for(int j=0; j<b; j++)
for(int k=0; k<c; k++)
loop();
return4;
}
...
void fn() {}
...
if ( for3(1, 2, 3, fn) ) printf("hellow world");
Call a function in which you pass a pointer to another function (the body of a loop, for example)
I didn't know it was possible to do this, but my goal is to write a complex multi-line macro that will execute many commands, probably a macro can't execute many commands and making it a function is not possible? Sometimes there is a need to extract for example a loop from a function, I was wondering if it's possible, maybe I'm writing nonsense.
I didn't know it was possible to do such a thing, but my task is to write a complex multi-line macro, which will execute many commands, probably a macro can't execute many commands and making a function out of it is impossible? Sometimes there is a need to make a loop out of a function, I wonder if it's possible, maybe I'm writing nonsense.
I don't know what the task is and whether you are digging there, but at a glance - another approach:
I didn't know it was possible to do such a thing, but my task is to write a complex multi-line macro, which will execute many commands, probably a macro can't execute many commands and making a function out of it is impossible? Sometimes I may need to make a loop out of a function, I wonder if it is possible, maybe I am writing nonsense.
This macro will be void, in order to return a result from it you need an expression to be calculated, in other words you need to call a function inside it, I've come to this conclusion.
Call a function in which you pass a pointer to another function (loop body, for example)
I studied a function pointer, to be honest I never understood what it's for, in fact you can call a function instead of a variable may come to me tightly, a function pointer resembles an overload or polymorphism.
I've been studying the function pointer, to be honest I haven't understood what it's for, basically you can call a function instead of a variable maybe I'm getting a hard time, the function pointer is like an overload or polymorphism.
You have some algorithm inside which you can put a sub-algorithm, so to speak, to "tweak" it to solve a particular problem. In essence, it's an analogue of virtual functions. The main thing is you asked for it yourself, and now you don't know why)), you had a framework, inside which you put a loop.
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.
it works!
Thank you!
Help me solve this problem. There is a macro and I want to add code inside it to return the result.
Is it possible to add code in the given place so that I could return the result from the macro? You can add the code; I tried it but if you write return, the effect is not expected. I saw this example
here in the thread where return works.
Help me solve this problem. There is a macro and I want to add code inside it to return the result.
Is it possible to add code in the given place so that I could return the result from the macro? You can add the code; I tried it but if you write return, the effect is not expected. I saw this example
here in the topic where return works.
Call a function in which you pass a pointer to another function (loop body, for example)
Call a function in which you pass a pointer to another function (the body of a loop, for example)
I didn't know it was possible to do this, but my goal is to write a complex multi-line macro that will execute many commands, probably a macro can't execute many commands and making it a function is not possible? Sometimes there is a need to extract for example a loop from a function, I was wondering if it's possible, maybe I'm writing nonsense.
I didn't know it was possible to do such a thing, but my task is to write a complex multi-line macro, which will execute many commands, probably a macro can't execute many commands and making a function out of it is impossible? Sometimes there is a need to make a loop out of a function, I wonder if it's possible, maybe I'm writing nonsense.
I don't know what the task is and whether you are digging there, but at a glance - another approach:
This way you can replace any piece of function (not necessarily array filling as it is in my case) and instantiate it as needed.
I didn't know it was possible to do such a thing, but my task is to write a complex multi-line macro, which will execute many commands, probably a macro can't execute many commands and making a function out of it is impossible? Sometimes I may need to make a loop out of a function, I wonder if it is possible, maybe I am writing nonsense.
It is possible, but not like this.
You can, but not like this.
This macro will be void, in order to return a result from it you need an expression to be calculated, in other words you need to call a function inside it, I've come to this conclusion.
Call a function in which you pass a pointer to another function (loop body, for example)
I studied a function pointer, to be honest I never understood what it's for, in fact you can call a function instead of a variable may come to me tightly, a function pointer resembles an overload or polymorphism.
I've been studying the function pointer, to be honest I haven't understood what it's for, basically you can call a function instead of a variable maybe I'm getting a hard time, the function pointer is like an overload or polymorphism.
You have some algorithm inside which you can put a sub-algorithm, so to speak, to "tweak" it to solve a particular problem. In essence, it's an analogue of virtual functions. The main thing is you asked for it yourself, and now you don't know why)), you had a framework, inside which you put a loop.