View Full Version : [NEED HELP] SDK Compiling Error: C2086
Grave Oct 30, 2006, 12:15 AM While compiling the C++ files, I got this error message:
Project : CvGameCoreDLL
Compiler : Microsoft Visual C++ Toolkit 2003 (called directly)
Directory : D:\Games\Sid Meier's Civilization IV\Warlords\CvGameCoreDLL\
--------------------------------------------------------------------------------
Switching to target: Final Release
CvArea.cpp
CvArtFileMgr.cpp
CvCity.cpp
CvCityAI.cpp
CvDLLButtonPopup.cpp
CvDLLEntity.cpp
CvDLLPython.cpp
CvDLLWidgetData.cpp
CvDeal.cpp
CvDiploParameters.cpp
CvFractal.cpp
CvGame.cpp
CvGameAI.cpp
CvGameCoreDLL.cpp
CvGameCoreUtils.cpp
CvGameTextMgr.cpp
CvGlobals.cpp
CvHallOfFameInfo.cpp
CvInfoWater.cpp
CvInfos.cpp
CvInfos.cpp(5955) : error C2086: 'int i' : redefinition
CvInfos.cpp(5891) : see declaration of 'i'
CvInfos.cpp(6070) : error C2086: 'int i' : redefinition
CvInfos.cpp(6049) : see declaration of 'i'
Process terminated with status 1 (3 minutes, 41 seconds)
2 errors, 0 warnings
This has never happened to me before when I compiled these files any other time... just now when I merged a new MODCOMP into my current work.
However, the lines of code where the errors are pointing to weren't altered or added by the new MODCOMP, the line of code remain unchanged, which is why this is really confusing me.
Any ideas on how to remedy this?
Déja Oct 30, 2006, 12:41 AM remove the second line that reads "int i;"
the compiler is complaning because you've already created a variable called "i" in line 5595 and you're trying to create another variable with the same name in the same scope. The second "int i;" on line 6070 (I'm guessing on the line numbers base on your error message) is what's causing the problem. Since i already exists as an int, it looks like you can safely remove the declaration.
However, if you do that, any code after that point will overwrite the i value from the earlier chunk of code. If you think you'll need it, then change the second i to something else and change all references of i to whatever you decide on for that relevant chunk of code.
If you have no idea what I'm talking about, say so and I'll try to explain it more clearly or point you to some better resources.
Grave Oct 30, 2006, 09:03 AM I think I understand. Now that I'm looking over the screenshots again, the variable in line 5595 is tied in with m_ppiBuildingYieldChanges, correct?
Then looking at line 6070, the variable is again tied in with m_ppiBuildingYieldChanges. Is that what's causing the problem, the double variable to the same item?
I wonder why it never came up as an error before... because both lines 5595 and 6070 are default coding. Would it be perhaps the new mod I just added also has variables in it as well? (You can kinda see it in the line 6070 screenshot towards the top).
Déja Oct 30, 2006, 10:41 AM I don't know where it came from, but you only need to declare the integer variable i once in a scope. Removing that second declaration will fix everything in that screenshot.
Grave Oct 30, 2006, 12:18 PM I certainly hope so!
I'll play around with it tonight and post my findings on here.
Impaler[WrG] Oct 30, 2006, 02:43 PM Me thinks it was taking a larger then nessary copy chunk from the mod you were incorporating. The i variable is usualy declared at the start of the function and used throughout for all the loops. The mod you were copying from probably had its inserted chunk right below that i declaration and it was either mislabled as part of the change block or you copied it by mistake.
Grave Oct 30, 2006, 04:59 PM I don't know where it came from, but you only need to declare the integer variable i once in a scope. Removing that second declaration will fix everything in that screenshot.
Well, I removed the variable at line 6070 and recompiled...
... now only one error pops up, and it's the same one as before with line 5595.
Project : CvGameCoreDLL
Compiler : Microsoft Visual C++ Toolkit 2003 (called directly)
Directory : D:\Games\Sid Meier's Civilization IV\Warlords\CvGameCoreDLL\
--------------------------------------------------------------------------------
Switching to target: Final Release
CvInfos.cpp
CvInfos.cpp(5955) : error C2086: 'int i' : redefinition
CvInfos.cpp(5891) : see declaration of 'i'
Process terminated with status 1 (0 minutes, 16 seconds)
1 errors, 0 warnings
Grave Oct 30, 2006, 05:02 PM ']Me thinks it was taking a larger then nessary copy chunk from the mod you were incorporating. The i variable is usualy declared at the start of the function and used throughout for all the loops. The mod you were copying from probably had its inserted chunk right below that i declaration and it was either mislabled as part of the change block or you copied it by mistake.
I'm pretty sure I copy/pasted correctly... I have a pretty decent file comparer program. But I'll look over everything again just to make sure.
Grave Oct 30, 2006, 05:52 PM Here is a cross reference link that may help shed a little light:
It's to Aussie_Lurker's Civics Balancer mod:
http://forums.civfanatics.com/showthread.php?t=190462&page=2
Impaler[WrG] Oct 30, 2006, 06:43 PM line 5955 is also unessary, the compiler flaged all re-declarations so the original two errors were respectivly the 2nd and 3rd atempts to declare in the same scope, you only removed one of the two errors. The original is probably way up at the start of that function, infact its telling you its on line (5891)
Déja Oct 30, 2006, 08:27 PM Yes, Impaler's correct.
Grave Oct 31, 2006, 09:05 AM So in summary, I guess it would be safe to say that the most recent modcomp I added to my project is the reason my compiler is throwing these errors?
Would a new mod really make lines 5955 and 6070 unnecessary? I noticed the new mod has added it's own "i" variable... You can kinda see it at the top of the 6070 screenshot.
I did try a little experiment: I kept the original variables on lines 5955 and 6070, and instead cut the code underneath the "i" variable in the new modcomp (see 6070 screenshot towards the top) and pasted it underneath the line 6070 variable. Re-compiled and no errors came up.
BUT... I'm still getting an in-game glitch where everything in the build que and Techs to research all take one turn (the main issue I'm having with this), which makes me think there might be a bug with the new modcomp I'm trying to add to my project.
But this was a good learning experience, thanks for all the help so far, gents. :)
Déja Oct 31, 2006, 09:58 AM If you're having difficulty understanding why the int i; is causing problems, I'd recommend reading a tutorial on scope in C++. A quick dash to google came up with this one: http://www.zeuscmd.com/tutorials/cplusplus/19-Scope.php
|
|