Cannot Compile 0.7 In MinGW with G++ 5.1

Started by Ruckamongus, 07 May 2015, 10:03:35

Ruckamongus

Hello, all. I've ran into some issues when compiling the latest 0.7 source. I've been using 0.7 for a while now (5 months or more I believe, and this was on GCC 4.8; I haven't updated since that time). Unfortunately, when calling make after configuring with cmake, I'm getting some static assert errors about invalid point-to-member function stuff. Here's a pastebin: https://pastebin.com/VxJXXfKJ

Part of the error:
Code (cpp) Select

In instantiation of 'struct std::_Bind_check_arity<void (tgui::ComboBox::*)(), tgui::ComboBox*&, int>':
(SNIP template redundancy stuff)
required from 'unsigned int tgui::SignalWidgetBase::connect(const string&, Func, Args ...) [with Func = void (tgui::ComboBox::*)(); Args = {tgui::ComboBox*}; std::__cxx11::string = std::__cxx11::basic_string<char>]'
C:\Users\Cody\Downloads\TGUI-0.7-dev\TGUI-0.7-dev\src\TGUI\ComboBox.cpp:505:92:   required from here
c:\mingw\mingw\include\c++\5.1.0\functional:1426:7: error: static assertion failed: Wrong number of arguments for pointer-to-member
       static_assert(_Varargs::value


I've used a great deal of 0.7 stuff in my project so I'd rather not go back to 0.6 if it can be avoided. Any help you can provide would be much appreciated!

texus

#1
Shit, GCC 5 seems to have added static asserts to prevent wrong binding. The problem is that it is also asserting when it shouldn't. I'm relying on that code to detect what parameters the user passes. It worked fine in previous gcc and clang versions and it was even written in such a way that VS2013 can compile it although not supporting it (which is why this part of the code is very sensitive and can't easily be changed).

You could try compiling with -std=c++1y, since std::function is actually only unambiguous in c++14 standard but it worked fine in c++11 with gcc 4.8. If that doesn't work then I'm starting to fear that I will have to dump the most advanced part of my library.

But you won't have to go back to v0.6, I think I will be able to disable code in such a way that you get the same behavior as VS2013 currently has: only basic calls to the connect function (all internal calls are like that) and for getting actual callback you would have to use connectEx.

texus

#2
I tested it myself by now, even with c++14 it won't compile.

For now I have just disabled part of the callback system when the compiler version is 5. When you read the tutorials, just pretend you have a Visual Studio compiler, so when it says "gcc 4.8 or higher" then you can forget about using that part.

I will try to minimize the failing code when I have some more time and go ask the gcc developers if this is a mistake in their compiler or if I am just doing something illegal.

Edit: I figured out the mistake while minimizing the code. The problem is in my code, although I don't immediately see a way around it.

texus

#3
You should check out the v0.7-dev-gcc5 branch. I still have to do some tests to check if it still works on all other compilers, but it seems to work with gcc 5.

Fixed in the latest version of v0.7-dev branch.

Ruckamongus