Moving the kernel to modern C
Moving the kernel to modern C
Posted Feb 28, 2022 17:06 UTC (Mon) by ianmcc (guest, #88379)In reply to: Moving the kernel to modern C by jem
Parent article: Moving the kernel to modern C
That might be valid C (although I don't know why, but it doesn't give any errors in an online C compiler). It isn't valid C++. The scope of the control variable declared in the for loop is the loop itself, so you can't declare another variable with the same name in the same scope.
for (int i = ..)
{
int i = 2; // not valid C++. There is already a variable 'i' declared in this scope
}
