Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3029

Compiler flag '/vd2'

$
0
0
I don't know how many of you are familiar with Glib and Gtk+. They're part of a suite of libraries which often get used to produce cross-platform GUIs (a bit like Qt etc). Each library has an object oriented counterpart which is designated by adding "mm" to the end of the library name (so there's glibmm / gtkmm etc). glibmm is the 'base level' library and most glibmm objects are derived from Glib::Object

A few days ago (quite by chance) I discovered from a post on the glibmm mailing list that anything which links to glibmm (and which also gets built with MSVC) needs to get built with the compiler flag /vd2 (described here).

Actually, that's not strictly true... If you only use objects from glibmm, you don't need the /vd2 switch. But if you define your own classes which are (ultimately) derived from Glib::Object, you need to set /vd2. I decided to check those other OO libraries (atkmm / gdkmm / pangomm / gtkmm) and sure enough, they all get built using /vd2 . As such, I assumed it would be prudent to build my own programs that way too.

When I read the above MSDN article it seemed to me as if /vd2 was reasonably safe to use (regardless of whether or not it was actually needed). So I looked through my current project for any module that was linking to glibmm and I rebuilt everything with the appropriate /vd2 flags set. If a given module didn't link to glibmm, I didn't bother setting the flag.

But I'm now seeing spurious crashes in odd places - in fact, often when the program shuts down and the CRT is cleaning up (stopping threads / detaching DLLs or whatever). So maybe I was wrong when I assumed that /vd2 is a 'safe' compiler switch. Can anyone shed any light on when it might NOT be safe to use /vd2?

[Edit...] In that MSDN article I posted to, I just noticed that for VS2005, VS2008 and VS2010 there's a statement at the top of each article:-

Quote:

/vd supports incorrect behavior in an early version of Visual C++, and is no longer needed.
so I'm guessing that from VS2012 onwards, the /vd compiler flag isn't relevant. However, for internal reasons, I'm stuck with VS2005 so it's still appropriate in my particular case... :(

Viewing all articles
Browse latest Browse all 3029

Latest Images

Trending Articles



Latest Images