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
A note to programmers:
Now if we need to edit an enumeration, we edit once and in one place. We need to add a new element, for example element_new = 56, we add
And we don't bother editing function get_enumqq_array(). The technique is called X Macro https://en.wikipedia.org/wiki/X_Macro. If developers wish, they can easily modify standard enumerations in a similar way.
Maybe not immediately obvious, the enumeration turned out this way:
Cool! I didn't know about the X Macro, thank you! I just do not understand the code, why there is no error because of the comma at the end of definition ENUM_QQ_HELPER. There should not be a comma after the last element when defining enum or array. But the compiler doesn't seem to swear at it for some reason.
I tried
it won't. And the array size (enum) is as it should be. It's cool! It seems to be a bug, but I'd rather have such a bug. Really, it is convenient.
Well, it's a legitimate violation, especially for all sorts of "stuff" like this, apparently. Don't worry about it, it's not an error in C/C++ either.
SZZ: in C++ standard on the subject of initialization:
braced-init-list:
{initializer-list , opt}
{ }
I.e. the comma at the end of braced-init-list is legalised at the highest level.
That is, the comma at the end of the braced-init-list is legalised at the highest level.
A note to programmers:
What about the normal names that are in the comments?
What about the normal names that are in the comments?
What about the normal names that are in the comments?
Yes, inserting a comment doesn't work. Unfortunate syntax for commenting on enums.
Can I have an example of the enum in question?
Yes, it doesn't work to insert a comment. Unfortunate syntax for commenting on enumerations.
Conclude it in /*...*/.
enum E {
a = 1, --**-- Комментарий_1
b = 2 --**-- Комментарий_2
};
The thing here is that the preprocessor doesn't want to eat comments (both // and /*), it doesn't expect to see them when macros are expanded. Either change the rules for preprocessor, or introduce alternative way to comment enumerations (comment will be displayed when running the script in settings), like this:
enum E {
a = 1, --**-- Комментарий_1
b = 2 --**-- Комментарий_2
};
Preprocessing is done in several steps. At first, all comments are removed from the source code and the result is sent for processing. And this is where the preprocessor does not expect to encounter a comment (when it opens the macros). It will consider such an encounter as an error. For example, here:
At first sight, this harmless code should contain a comment. But it won't compile.