“:-!!” what is it in c code?
stackoverflow.com
stackoverflow.com
The guy asking the question just misread the code, the colon is part of the struct definition and the key part is -!! which coerces an integer to 0 if the value is zero, or -1 if the value is anything other than 0.
edit: Another common one is using __LINE__ or __COUNTER__ in an array symbol name and having the test value result in an array size of -1.
for (int i = 42; i --> 0;) { foo(); } #define ARRAYSIZE 42
int array[ARRAYSIZE];
void f() {
for (i=ARRAYSIZE; i --> 0;) {
printf("%d\n", array[i]);
}
}
If it were to start at 42 you'd be referencing the array outside of its bounds. for(int i=0; i --> 42;) { bar(); }Didn't get much attention back then. (+8 at time of writing)