[MSVC] - Compiler option "/vd2"



This is the conversation that was previously named:-

[Windows] Trash in sigc::trackable::callback_list_ when class is derived from Glib::Object

(mostly, a discussion between Marcin Kolny and myself). After a bit of detective work we eventually concluded that where a programmer derives a class from Glib::Object (when building with MSVC) it's necessary to set the compiler flag "/vd2" during compilation. Marcin gave this simple example:-

class Test : public Glib::Object
{
public:
    Test()
    {
    }
};

When instantiating the above class, we could see that the member variable 'callback_list_' wasn't getting initialised correctly with most versions of MSVC. Adding the flag '/vd2' fixed the problem. I checked the higher level libraries (atkmm / gdkmm / pangomm / gtkmm) and discovered that all except for cairomm do indeed have this flag set during compilation. So it seemed reasonable to apply it to my own programs (wherever they might declare objects derived from Glib::Object). It certainly seemed to do the trick for the above example.

However... I'm noticing that for more complex programs, the 'vd2' flag tends to cause strange runtime crashes - especially so in libsigc++ (remember that the variable 'callback_list_' is of type 'sigc::trackable'). Currently I'm not building libsigc++ with the '/vd2' flag enabled. Maybe I should be?? Is there any official advice regarding this for MSVC devs? At the moment, adding that flag seems to have caused me a lot more problems than it solves... :-(

Thanks, John


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]