"syntax error : missing ';' before '{'" in c++ project with precompiled header -
when trying compile simple c++ project, following error:
syntax error : missing ';' before '{' i did research. compiler doesn't allow declaration of variables inside of loop, inconvenient me. if declare loop variables before loop, error disappears.
this c++ project "stdafx.h" precompiled header.
is compiler behavior (c89) enforced fact i'm using precompiled header or did scr**ed config in past ? there way of circumventing befavior ?
p.s. i'm using visual studio 2012 on windows 7 64-bit;
code samples:
error on first line
for (int idx = 0, int = 100; idx < (sizeof(antestscores) / sizeof(int)); i++, idx++) { antestscores[idx] = i; }this compiles
int idx; int i; (idx = 0, = 100; idx < (sizeof(antestscores) / sizeof(int)); i++, idx++) { antestscores[idx] = i; }
go with
for (int idx = 0, = 100; idx < (sizeof(antestscores) / sizeof(int)); i++, idx++) { antestscores[idx] = i; } this declares two variables of type int in first statement of for loop.
the reason works , other attempt doesn't follows:
each declaration statement has separated each other ;, same ; used separate parts of for(;;) loop's header tried around using ',' operator. didn't work due syntax error
Comments
Post a Comment