Ive narrowed it down but im still stuck. It's these sections below that causes the debug assertion failure. It triggers when i try to clear the list after it has been populated with armies from disk.
Save armies to disk
saveNum(armyList);
loop2(army, armyList)
fileSave(uu);
endLoop
Load armies from disk
loadNum
for (int ii = 0; ii < num; ii++){
armyList.push_back(army());
army * uu = &armyList.back();
fileLoad(theNewArmy);
}
Defines used in these sections (these work fine in many other places so i dont think the problem is here):
#define saveNum(myList) num = myList.size(); fwrite( &num, sizeof(num), 1, f);
#define loadNum fread( &num, sizeof(num),1,f);
#define fileSave2(item) fwrite(&item.startSave,1,&item.endSave-&item.startSave,f);
#define fileLoad2(item) fread( &item.startSave, 1,&item.endSave-&item.startSave, f);
#define loop2(classType,myList) \
{std::list<classType>::iterator it; \
for ( it = myList.begin(); it != myList.end(); ++it ){ \
classType * uu=&(*it);
I'm aware that these save/load defines are not safe (will indead crash) when I change the content of the class saved, but thats fine for now.