I’ve created this simple program to auto-generate sequence of frames to be used in Avisynth scipt:
#include <stdio.h>
int main(void) {
const int step = 3;
const int arr[] = {31997, 31998, 32001};
int i, ii = 0;
for(i = 32002; i <= 32121; i += step, (sizeof(arr)/sizeof(int) - 1 ) != ii ? ++ii : ii = 0) {
printf("freezeframe(%d,%d,%d)\n", i, i + step, arr[ii]);
}
return 0;
}
Using MinGW with GCC 4.6.2, I get this error: lvalue required as left operand of assignment.
The issue is simply solved by using parenthesis around ii=0. However, I don’t get why it is an error. Shouldn’t the assignment operator be evaluated first?
Wikepedia has a short section which explains this: http://en.wikipedia.org/wiki/Operators_in_C_and_C++#Notes
The grammar for conditional operator in C is
Note that an
assignment-expressionis not considered aconditional-expression, and a conditional expression cannot be the left of an assignment expression and so it’s technically a syntax error. See the grammar: http://www.lysator.liu.se/c/ANSI-C-grammar-y.htmlHowever, GCC is (incorrectly) parsing it as:
Which is a semantic error since
++iis not an lvalue expression.