GNOME Bugzilla – Bug 570620
Using LibXML++ under MSVC gives many warnings
Last modified: 2020-11-11 09:06:56 UTC
Please describe the problem: When you use the LibXML++ bindings with the Microsoft Visual C++ Compiler (version 8.0 and 9.0) you get the following warning :\Program Files\gtkmm\include\libxml++-2.6\libxml++/exceptions/exception.h(46): warning C4251: 'xmlpp::exception::message_' : class 'Glib::ustring' needs to have dll-interface to be used by clients of class 'xmlpp::exception' Steps to reproduce: 1. Compile any project using LibXML++ and Visual Studio 2005/2008 Actual results: The following warning occurs on every include of libxml++ :\Program Files\gtkmm\include\libxml++-2.6\libxml++/exceptions/exception.h(46): warning C4251: 'xmlpp::exception::message_' : class 'Glib::ustring' needs to have dll-interface to be used by clients of class 'xmlpp::exception' Expected results: No warning Does this happen every time? Yes Other information: I've fixed the warning as follows: add the following forward declaration to libxml++\exceptions\exception.h class GLIBMM_API Glib::ustring;
Should the change be made in glibmm? If so, please provide a patch for glibmm.
CCing Armin in case he has ideas.
I think the warning is because xmlpp::exception is declared with LIBXMLPP_API (which is __declspec(dllimport)) but Glib::ustring is not. I have never completely understood why these specifications are actually needed since most things seem to work well without; most things in glibmm and gtkmm do not use them. However I see that Cedric added this in 2006, and he probably had good reasons in doing so. So I think the way to go about that is to add GLIBMM_API to Glib::ustring in glibmm.
> So I think the way to go about that is to add GLIBMM_API to Glib::ustring in > glibmm. Well, feel free to do that, I guess.
Arjan, a patch would be welcome.
libxmlplusplus (a.k.a. libxml++) can now be built with MS Visual Studio. See the MSVC_NMake/README file. Different versions of libxml++ require different versions of MSVC, Visual Studio 2015 (MSVC 14.0) or later for libxml++-2, Visual Studio 2017 (MSVC 16.0) or later for libxml++-3. libxml++ is now stored at GitHub, https://github.com/libxmlplusplus/libxmlplusplus