I am trying to optimize code so that the embedded system runs faster. Here is my question:
Can someone explain to me why this doesn't compile.
Here the while loop is simply introducing a delay. "delay" is actually a complicated function that eventually returns 0. The details of this is irrelevant. Notice i didn't put any bracket near the while loop or any semicolon but instead i put a comma (because i'm inside an "if" statement, i cannot use a semicolon). We know that the result of the comma separated list is the last element of the list. The result of the argument of the if statement is B. While this doesn't compile, i can create a function that is equivalent:Code:BYTE B; B = 1; if(while(delay), B){ ... }
The latter will compile but i want to avoid a function call because that adds overhead. My ultimate goal is to optimize the code. Why is the function call compiling and not the earlier code. What can i do to make it compile without using a function call? A "for" loop doesn't work either and i cannot use goto statements. I don't want to use machine code at this time unless i don't have a choice. My compiler doesn't allow "inline" functions. Is this even possible?Code:BYTE func(void) { BYTE B; B = 1; whille(delay); return B; } Then i can do the following: if(func()){ ... }