GNOME Bugzilla – Bug 147311
sigc::bind causes unwanted pass-by-value behavior with MSVC++ 7.1
Last modified: 2004-12-22 21:47:04 UTC
Microsoft's VC++ 7.1 compiler (aka VC++2003, aka v. 13.10.3077 by the compiler's versioning scheme) cannot compile libsigc++ 2.0.3 without first disabling the LIBSIGC_TEMPLATE_PREFIX macro. Unfortunately, the check that controls LIBSIGC_TEMPLATE_PREFIX also controls the use of sun_forte_workaround, so disabling one enables the other. With the MS VC++ 7.1 compiler, calling sun_forte_workaround somehow causes arguments to be passed by value even when using reference types. Decoupling sun_forte_workaround and LIBSIGC_TEMPLATE_PREFIX to have separate, independent checks and using operator() instead of sun_forte_workaround seems to fix this issue with MSVC++.
Created attachment 29420 [details] sigc::bind copy test Test case attached. The code passes an object with a private, undefined copy-constructor to a signal declared to accept it by reference. If sun_forte_workaround is enabled, sigc::bind attempts to copy the object and generates a compile-time error.
Adding the PATCH and 'portability' keywords.
Modified configure check to decouple LIBSIGC_TEMPLATE_PREFIX and sun_forte_workaround. Discussion on ml yields that configure is not executed in the MSVC environment. => Awaiting patch for the MSVC project file that lets the compiler define SIGC_CXX_MSVC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD.
> => Awaiting patch for the MSVC project file that lets the compiler define > SIGC_CXX_MSVC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD. Hm, it seems that this was nonsense. In fact, sigc++config.h needs to be configured according to the platform. Normally, this is done by the configure script. What options do we have with MSVC?
I don't think adding those definitions to the project file is a good idea, since some of the header files depend that sigc++config.h simply exists, and modifying adaptor_trait.h to include sigc++config.h conditionally seems kind of ugly. IMO it might be better to include a pre-generated copy of sigc++config.h suitable for MSVC7.1 in the MSVC_Net2003 project directory.
Created attachment 30159 [details] [review] Patch to make libsigc++ more MSVC-friendly Summary of changes: * Added SIGC_API qualifier to all externally-visible non-template classes/structs. * Added #include <sigc++config.h> to the files that use SIGC_API. * Added empty SIGC_API definition to sigc++config.h.in for non-MSVC compilers. I'm not sure if this is the right place to put this (probably not). * Added MSVC-specific sigc++config.h to the MSVC project directory. (The comment in it probably should be edited.) * Changed MSVC project settings to output a multi-threaded DLL, set the include paths to work (hopefully) out-of-the-box. Disabled precompiled headers, since they just complicate things and shouldn't be necessary for such a relatively project.
Committed to cvs. Thanks a lot! Please add the Changes summary to 'ChangeLog' for future patches. -> Closing in the assumption that the patch solves the configure problems for MSVC.