Game Development Community

Visual Studio 2012 tips

by Daniel Buckmaster · in Torque 3D Professional · 09/16/2012 (4:45 pm) · 8 replies

Hey all. I just had to migrate hard-drives, and took the opportunity to install VS 2012. It's pretty crazy! It took a few small steps to get 1.2 to compile under it, so I figured I'd note them down.

1. You'll get a ton of errors in xkeychech.h caused by #defining keywords. In this case, it's a #define for in Engine/source/platform/types.visualc.h and Engine/source/platform/typesWin32.h. Just do a search for '#define for' and you'll get them. Simply comment them out. Apparently they were there to fix a bug in VS's scoping of variables in for loops, which I hope has been fixed since. I seemed to be able to run the engine fine...

2. There will be linker errors relating to the SAFESEH option. I'm not really sure what it does, but you can disable it by right-clicking on the Torque 3D DLL project, then going Properties > Linker > Advanced and setting 'image has safe exception handlers' near the bottom to No.

Happy VSing!

About the author

Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!


#1
09/17/2012 (2:16 am)
Ooh neat! I just compiled the problem causing files with the VS 2010 compiler, but this seems like a better solution! :)
Edit: not sure but SAFESEH might be necessary to do "Edit and continues" getting this:
Warning	44	warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification	C:\Users\Lukas\Google Drev\Torque3D1.2\Examples\FPS Example\buildFiles\VisualStudio 2010\projects\main.obj	FPS Example

And a couple of these:
Warning	37	warning C4258: 'i' : definition from the for loop is ignored; the definition from the enclosing scope is used	c:\users\lukas\google drev\torque3d1.2\engine\source\t3d\shapebase.cpp	3313	1	FPS Example DLL

When doing this:
updateAnimThread(i, getImageShapeIndex(image));
The C4258 also applies to a couple of other functions.
#2
09/17/2012 (6:43 am)
The C4258 seems to indicate the scoping is working correctly, at least.

I've never used edit-and-continue... maybe there's something in that. All I know is that SAFESEH caused about 800 errors and I wasn't about to go through and figure out what they were ;P. I imagine it could be simple stuff, but for now I'm happy with just turning it off.
#3
09/20/2012 (12:22 pm)
I think the problem with the 'for' loop might be due to the 'macroization' of 'for' in T3D that was used as a workaround for an older VS bug.
#define for if(false) {} else for   ///< Hack to work around Microsoft VC's non-C++ compliance on variable scoping
This is in platform/types.visualc.h, line 74.
#4
09/22/2012 (5:52 pm)
I fixed it in my fork. Am I right in thinking this issue has actually been fixed since VS2005? In any case, what I've done is guard those two #defines with a check against _MSC_VER < 1700, since #defining for doesn't actually cause errors until 1700.
#5
03/25/2013 (2:19 pm)
Regarding /safeseh issue, it's solved this way:

1) download a newer version of NASM from here:
www.nasm.us/pub/nasm/releasebuilds/2.10.07/win32/

2) put it into Engine/bin/nasm folder;

3a) rename downloaded "nasm.exe" and "ndisasm.exe" to "nasmw.exe" and "ndisasmw.exe" accordingly, replacing the old files;

OR

3b) open your *DLL.vcxproj file with any text editor and replace all instances of "nasmw.exe" and "ndisasmw.exe" with "nasm.exe" and "ndisasm.exe"

Newer NASM binaries should definitely go into HEAD so this problem never appears again. More and more people use VS12 these days.
#6
03/26/2013 (2:12 pm)
Thanks for that! Do you feel like creating a pull request? If not, I'll do it - it'd be great to have easier 2012 support.
#7
03/26/2013 (3:14 pm)
Will do. Come to think of it, I've accumulated quite a bunch of bugfixes during all these years with Torque. Haven't seen most of them implemented in the latest revision. It may be a good time to share.

EDIT: done (vs 2012 updates).
#8
08/02/2014 (6:42 am)
"There will be linker errors relating to the SAFESEH option. I'm not really sure what it does, but you can disable it by right-clicking on the Torque 3D DLL project, then going Properties > Linker > Advanced and setting 'image has safe exception handlers' near the bottom to No."

that solved my problem with edit and continue.

"Edit: not sure but SAFESEH might be necessary to do "Edit and continues" getting this:"

@lukas,
on my side that is totally different.
setting that to no made my VS13 to work with edit and continue.
+For the first time i was able to change unreal engine's c++ code without restart..
it was painful for long restart time.