GNOME Bugzilla – Bug 767777
Fix compilation of sigc++/functors/slot.h on non-GCC
Last modified: 2016-06-21 09:21:41 UTC
Hi, The commit 6e5eee0 ("Implement slot<R(Arg...)> with variadic template") broke the build of anything on non-GCC that would make use of sigc++/functors/slot.h as the syntax used for calling operator() varies between compiler when used in a variadic templates scenario. As done elsewhere in the code, we can make use of the SIGC_WORKAROUND_OPERATOR_PARENTHESES to replace "template operator()" so that the correct syntax is used when building code. I will attach a patch for this shortly. With blessings, thank you!
Created attachment 329926 [details] [review] Update to sigc++/functors/macros/slot.h.m4 Hi, Here comes the patch. With blessings, thank you!
Thanks. This is with the MSVC++ compiler, right? Which version? Please mention that in the commit message. Are you sure that this is the commit that broke the build? https://git.gnome.org/browse/libsigcplusplus/commit/?id=6e5eee0
Created attachment 329927 [details] [review] Update to sigc++/functors/macros/slot.h.m4, with updated commit message Hi Murray, (In reply to Murray Cumming from comment #2) > Thanks. This is with the MSVC++ compiler, right? Which version? Please > mention that in the commit message. Yes indeed, so I added a part that mentions this. This applies for VS2015 as well. > Are you sure that this is the commit that broke the build? > https://git.gnome.org/browse/libsigcplusplus/commit/?id=6e5eee0 Yup, seems like it to me. The change that made use of template operator() was added there. It looks like that is the reason why the macro was introduced to cover for that scenario of "template operator()" and "operator()" and the case for the Sun Forte compiler, AFAICT. With blessings, thank you!
This seems to be my fault. But please see what I wrote about SIGC_CXX_MSVC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD in bug 762065 comment 0. Bjarne Stroustrup, "The C++ Programming Language", 4th ed., section 26.3.1 has this example: template <typename Alloc> void f(Alloc& all) { int* p1 = all.get<int>(); // syntax error: get() is assumed to // name a non-template int* p2 = all.template get<int>(); // OK: get() is assumed to be a template // ... } I thought that most compilers by now accepted the syntax that Stroustrup says is the only correct one.
Hi Kjell, I see, the exact error I got was error C2059: syntax error: 'template', so somehow what Stroustrup mentioned did not make it to Visual Studio..., even 2015 :|. With blessings, thank you!
Created attachment 330072 [details] Test case for template keyword template operator()<>() or only operator()<>()? It's more difficult than I thought. See the attached test case. I've tested your patch with gcc. As expected, no problem. Please push it. The reason I didn't do it like this in the commit you mention, was probably that I copied that code from the master branch. SIGC_WORKAROUND_OPERATOR_PARENTHESES has been removed there, and I didn't think of adding it in the copy in the libsigc++-2-10 branch.
Hi Kjell, Thanks for the test case--I have pushed the patch as ac79b55 in libsigc++-2-10. I will close the bug now. With blessings, thank you!
Thanks, Fan. Maybe you would like to file a bug for the MSVC++ 2015 compiler with Microsoft? They have made many statements recently about wanting to be C++14 compliant, so there is some hope that they might fix this.