This approach probably doesn't work anywhere. As there is a substitution going on where the VALUE on the right is undefined.
And it's evil to change someone else's macro substitution. All the more so, if these are predefined environment macros. It doesn't matter where in the end the overriding macro will be, after all the project's files are assembled. It's better to define your own _VALUE macro.
Vladimir Simakov: And it's evil to change someone else's macro substitution. Especially if they are predefined environment macros. It doesn't matter where in the end, after all the files of the project are assembled, the overriding of the macro will end up. You'd better define your own _VALUE macro.
May I ask why you can't use the VALUE value assignment to a global variable and multiply it and substitute it in the final define?
Valeriy Yastremskiy: May I ask why you can't use a VALUE assignment to a global variable and multiply it and substitute it in the final define?
You can, but then the meaning of macro substitution is lost (substitute values in the code). All hope remains on the compiler, that it converts const type (have you, by the way, defined the variable type?) to c++ constexpr type
But otherwise, yes, you can.
#ifdef MACROS
const int gValue=2*VALUE;
#undef VALUE
#define VALUE gValue
#endif
This approach probably doesn't work anywhere. As there is such a substitution going on, where the VALUE on the right is not defined.
Apparently, I don't understand how the compiler works at all. I imagined that strings are parsed sequentially. So there is no undefined value on the right:
#define VALUE 10// VALUE = 10#define TMP VALUE // TMP = 10#undef VALUE // VALUE = EMPTY#define VALUE (TMP*2) // TMP = 10, следовательно VALUE = 20
Apparently, I don't understand how the compiler works at all. I imagined that strings are analysed sequentially. So there is no undefined value on the right:
Works top-down like text replacement. I.e. "TMP" will be replaced by "VALUE".
Apparently, I don't understand how the compiler works at all. I imagined that strings are analysed sequentially. So there is no undefined value on the right:
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.
So why doesn't it work?
Most likely, this approach doesn't work anywhere. Because there is a substitution going on where the VALUE on the right is undefined.
This approach probably doesn't work anywhere. As there is a substitution going on where the VALUE on the right is undefined.
Yes, and it is evil to change someone else's macro substitution.
Without this evil, it would not have happened.
And it's evil to change someone else's macro substitution. Especially if they are predefined environment macros. It doesn't matter where in the end, after all the files of the project are assembled, the overriding of the macro will end up. You'd better define your own _VALUE macro.
May I ask why you can't use a VALUE assignment to a global variable and multiply it and substitute it in the final define?
You can, but then the meaning of macro substitution is lost (substitute values in the code). All hope remains on the compiler, that it converts const type (have you, by the way, defined the variable type?) to c++ constexpr type
But otherwise, yes, you can.
But then, yes, you can.
It won't work with that.
It won't work with this one.
This approach probably doesn't work anywhere. As there is such a substitution going on, where the VALUE on the right is not defined.
Apparently, I don't understand how the compiler works at all. I imagined that strings are parsed sequentially. So there is no undefined value on the right:
Apparently, I don't understand how the compiler works at all. I imagined that strings are analysed sequentially. So there is no undefined value on the right:
Works top-down like text replacement. I.e. "TMP" will be replaced by "VALUE".
Apparently, I don't understand how the compiler works at all. I imagined that strings are analysed sequentially. So there is no undefined value on the right:
It's not the compiler - it's the preprocessor)
turns into
, and your VALUE is undefined.