This question is strictly related to C or C ++ language abilities. I do not suggest the code below as a design pattern, I do not use it and I do not encourage it. But I'm just curious to improve my information!
I have defined a label that contains a label and a goto condition.
#define BROP (number, zodiac) \ Num = rand_lcg (generated); \ If (num% 2) \ {\ rng1: \ generate = rand_lcg (generated); \ If (generated & lt; 512) \ sum - = generates; \ Else \ goto rng1; \}
and later code I use it like this:
for (i = 0; i & lt; iterations; i ++ ) {BROP (Num, sum); BROP (number, yoga); BROP (number, yoga); // ...}
I end up in a situation where the loop gets unearned and the label is redefined .
Is there a smart creation I can use to make the compiler label change every time defined "instantiated"?
I know about all the options to avoid this statement but still, I do not know the answer to the question.
You actually want to do this a do
... while < / Code> loop:
define #BROP (num, sum) {\ bool again = false; \ Num = rand_lcg (generated); \ If (num% 2) {\ do {again = wrong; \ Generate = rand_lcg (generated); \ If (generated & lt; 512) \ sum - = generates; \ Else \ again = true; \} While (again); } While looking for (0)
old external do {
...
} while (0)
move.
If you insist on (wrong) being a label and you are using the compiler (or should be compatible with it), then you can use the extension (i.e. __ label __
...)
You can also generate labels from the __ line __
number using the preprocessor. Take inspiration from
# Define STUPID_LOOP_BIS (Test, Lin) Do {\ Laboratory ## Lin: If (Test) Goto Lab ## Lin; } (0) #define STUPID_LOOP_AT (test, lin) STUPID_LOOP_BIS (test, lin) #define STUPID_LOOP (test) STUPID_LOOP_AT (test, __LINE__)
For unclear reasons All you need is three macro!
and use
STUPID_LOOP (x ++> <100); STUPID_LOOP (y--> 0);
On the different lines, of course, friendly and will improve for your needs.
You should definitely use and trust more compiler optimization capabilities and stable inline
function for each exam machine branch ( For example, because) does not compile; Each loop machine is not compiled for the loop (for example). You are probably losing your developer time, and more importantly, you are disabling adapt to your move (so your code will be slow, not fast).
If using GCC or Enable Clag Optimization and Warnings: then
GCC -Wall -Wextra -O3 -mtune = native
No comments:
Post a Comment