I can't seem to figure out what is causing the following error:
trainLine.cpp:108: error: name lookup of ‘i’ changed for new ISO ‘for’ scoping
trainLine.cpp:98: error: using obsolete binding at ‘i’
Here is the code that is causing the error:
int main()
{
pthread_t tidArray[NUM_TRAINS];
Train* trainArray[NUM_TRAINS];
for (int i = 0; i < NUM_TRAINS; i++)
trainArray[i] = new Train(TRAIN_NAME_ARRAY[i], TRAIN_TRANSIT_TIME_MSECS[i]);
int trainInd = 0;
pthread_create(&tidArray[i], NULL, initiallyNorthernly,(void*)&trainArray[i]);
pthread_create(&tidArray[i], NULL, initiallySouthernly,(void*)&trainArray[i]);
for (int i = 0; i < NUM_TRAINS; i++)
trainArray[i] = NULL;
pthread_join(tidArray[i], (void**)&trainInd);
return(EXIT_SUCCESS);
}
I apologize in advance, but I am very new to C/C++ and nothing is popping out as wrong to me. Possibly not placing brackets around for loop statements? Thanks in advance for any help.