I'm trying to use fstream for some file I/O, but I'm getting the following error:
any idea why this is occurring, and how to fix it?fstream (465) error C2061: syntax error : identifier '_DebugHeapTag'
BTW, Merry Christmas to everyone!
I'm trying to use fstream for some file I/O, but I'm getting the following error:
any idea why this is occurring, and how to fix it?fstream (465) error C2061: syntax error : identifier '_DebugHeapTag'
BTW, Merry Christmas to everyone!
Did you Google the error first?
Yes, I did. I found two different scenarios offered:
1) I'm using a mixture of old and new I/O headers and functions
2) I'm redefining the keyword new
I'm not actually writing a new program, but modding Civilization 4 Beyond the Sword, so while both of these scenarios are actually correct, I can't really go and change them without undoubtedly causing a lot of headaches. So, I'm hoping there's another way around it somehow.
can you show us what headers you're including?
Well, I'm modding the SDK for Civ4 BTS, so there are quite a few headers used. I searched for #include <, which should bring up all the headers not included in the SDK itself, and here's what I got:
As you can see, it's including stdio.h and I'm trying to include fstream. This (according to scenario #1) could be what's causing the problem.CvGameCoreDLL.h(17):#include <windows.h>
CvGameCoreDLL.h(18):#include <MMSystem.h>
CvGameCoreDLL.h(21):#include <crtdbg.h>
CvGameCoreDLL.h(23):#include <vector>
CvGameCoreDLL.h(24):#include <list>
CvGameCoreDLL.h(25):#include <tchar.h>
CvGameCoreDLL.h(26):#include <math.h>
CvGameCoreDLL.h(27):#include <assert.h>
CvGameCoreDLL.h(28):#include <map>
CvGameCoreDLL.h(29):#include <hash_map>
CvPlot.h(10):#include <bitset>
CvString.h(6):#include <string>
CyCity.h(10):#include <string>
CyMessageControl.h(6):#include <boost/python/list.hpp>
CyMessageControl.h(7):#include <boost/python/tuple.hpp>
FDialogTemplate.h(8):#include <windows.h> // This is needed just for the LPCSTR, DWORD, and WORD typedefs
CvGame.cpp(24):#include <set>
CvGameCoreDLL.cpp(5):#include <new>
CvGameCoreUtils.cpp(3):#include <algorithm>
CvInitCore.cpp(31):#include <shlobj.h>
CvSelectionGroup.cpp(23):#include <set>
CvSelectionGroup.cpp(53):#include <fstream> // This is where I'm trying to include fstream
CvXMLLoadUtilityModTools.cpp(17):#include <string>
CvXMLLoadUtilitySet.cpp(11):#include <algorithm>
FAssert.cpp(7):#include <tchar.h>
FAssert.cpp(8):#include <stdio.h>
FDialogTemplate.cpp(7):#include <tchar.h>
However, like I said in scenario #2, the keyword new is also redefined here:
I commented this line out and it allowed me to compile, but I'm pretty sure I need to keep it in there for the game to run properly, so I don't think this is a feasible solution.Code:#define new new(__FILE__, __LINE__)
Last edited by LyTning94; 12-25-2011 at 06:20 PM.
well you should know that new is a keyword in C++ and you cannot redefine its meaning. you can overload it, because it's an operator, but you cannot use it as a preprocessor macro.
Someone else familiar with the BTS SDK just told me it would be safe to comment out that line, so never mind.
Last edited by LyTning94; 12-26-2011 at 10:00 AM.