Error C2198 Functional header too few arguments.

Started by Maddoggaia, 18 May 2016, 04:41:45

Maddoggaia

Hello, I have been trying to compile one of the 0.7 examples provided (The login screen example functions, but the rest give the following errors)

Visual Studio 2013 update 5.
OS: Windows 8.1
SFML Version: 2.3.2
TGUI: Visual Studio 2013 x86. (Precompiled)
Both SFML and TGUI are Debug dynamically linked.

1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(1149): error C2198: 'void (__cdecl *)(std::string)' : too few arguments for call
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(1137) : see reference to function template instantiation 'void std::_Bind<true,void,void (__cdecl *const )(std::string),>::_Do_call<,>(std::tuple<>,std::_Arg_idx<>)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(1137) : see reference to function template instantiation 'void std::_Bind<true,void,void (__cdecl *const )(std::string),>::_Do_call<,>(std::tuple<>,std::_Arg_idx<>)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\xrefwrap(283) : see reference to function template instantiation 'void std::_Bind<true,void,void (__cdecl *const )(std::string),>::operator ()<>(void)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\xrefwrap(283) : see reference to function template instantiation 'void std::_Bind<true,void,void (__cdecl *const )(std::string),>::operator ()<>(void)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(228) : see reference to function template instantiation '_Ret std::_Callable_obj<std::_Bind<true,_Ret,void (__cdecl *const )(std::string),>,false>::_ApplyX<_Rx,>(void)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Rx=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(228) : see reference to function template instantiation '_Ret std::_Callable_obj<std::_Bind<true,_Ret,void (__cdecl *const )(std::string),>,false>::_ApplyX<_Rx,>(void)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Rx=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(226) : while compiling class template member function 'void std::_Func_impl<_MyWrapper,_Alloc,_Ret,>::_Do_call(void)'
1>          with
1>          [
1>              _Alloc=std::allocator<std::_Func_class<void,>>
1>  ,            _Ret=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(495) : see reference to class template instantiation 'std::_Func_impl<_MyWrapper,_Alloc,_Ret,>' being compiled
1>          with
1>          [
1>              _Alloc=std::allocator<std::_Func_class<void,>>
1>  ,            _Ret=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(396) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Do_alloc<_Myimpl,_Ty,_Alloc>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,void (__cdecl *const )(std::string),>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,>>
1>  ,            _Fty=std::_Bind<true,void,void (__cdecl *const )(std::string),>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(396) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Do_alloc<_Myimpl,_Ty,_Alloc>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,void (__cdecl *const )(std::string),>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,>>
1>  ,            _Fty=std::_Bind<true,void,void (__cdecl *const )(std::string),>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(385) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset_alloc<_Ty,std::allocator<std::_Func_class<_Ret,>>>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,void (__cdecl *const )(std::string),>
1>  ,            _Fty=std::_Bind<true,void,void (__cdecl *const )(std::string),>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,>>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(385) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset_alloc<_Ty,std::allocator<std::_Func_class<_Ret,>>>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,void (__cdecl *const )(std::string),>
1>  ,            _Fty=std::_Bind<true,void,void (__cdecl *const )(std::string),>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,>>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(671) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset<_Ty>(_Fty &&)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,void (__cdecl *const )(std::string),>
1>  ,            _Fty=std::_Bind<true,void,void (__cdecl *const )(std::string),>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(671) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset<_Ty>(_Fty &&)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,void (__cdecl *const )(std::string),>
1>  ,            _Fty=std::_Bind<true,void,void (__cdecl *const )(std::string),>
1>          ]
1>          c:\users\rei\documents\libraries\tgui-0.7\include\tgui\signal.hpp(153) : see reference to function template instantiation 'std::function<void (void)>::function<std::_Bind<true,void,void (__cdecl *const )(std::string),>>(_Fx &&)' being compiled
1>          with
1>          [
1>              _Fx=std::_Bind<true,void,void (__cdecl *const )(std::string),>
1>          ]
1>          c:\users\rei\documents\libraries\tgui-0.7\include\tgui\signal.hpp(153) : see reference to function template instantiation 'std::function<void (void)>::function<std::_Bind<true,void,void (__cdecl *const )(std::string),>>(_Fx &&)' being compiled
1>          with
1>          [
1>              _Fx=std::_Bind<true,void,void (__cdecl *const )(std::string),>
1>          ]
1>          c:\users\rei\documents\libraries\tgui-0.7\include\tgui\signal.hpp(152) : while compiling class template member function 'std::function<void (void)> tgui::priv::connector<type,Func>::connect(Func,size_t)'
1>          with
1>          [
1>              Func=void (__cdecl *)(std::string)
1>          ]
1>          c:\users\rei\documents\libraries\tgui-0.7\include\tgui\signal.hpp(240) : see reference to function template instantiation 'std::function<void (void)> tgui::priv::connector<type,Func>::connect(Func,size_t)' being compiled
1>          with
1>          [
1>              Func=void (__cdecl *)(std::string)
1>          ]
1>          c:\users\rei\documents\libraries\tgui-0.7\include\tgui\signal.hpp(240) : see reference to class template instantiation 'tgui::priv::connector<type,Func>' being compiled
1>          with
1>          [
1>              Func=void (__cdecl *)(std::string)
1>          ]
1>          c:\users\rei\documents\libraries\tgui-0.7\include\tgui\signal.hpp(354) : see reference to function template instantiation 'void tgui::Signal::connect<void(__cdecl *)(std::string),>(unsigned int,Func)' being compiled
1>          with
1>          [
1>              Func=void (__cdecl *)(std::string)
1>          ]
1>          c:\users\rei\documents\projects\sfml projects\sfmltgui\sfmltgui\main.cpp(21) : see reference to function template instantiation 'unsigned int tgui::SignalWidgetBase::connect<void(__cdecl *)(std::string),>(const std::string &,Func)' being compiled
1>          with
1>          [
1>              Func=void (__cdecl *)(std::string)
1>          ]


Any help with this would be handy, I have not changed the original Example code, so it's merely a copy and paste job to see if there would be any problems with compiling...

I did a search for the above errors, but most of what I was seeing was to do with a different functional header, and for older versions of TGUI.

texus

Could you show the line in your main function where it goes wrong?
In the error it says "main.cpp(21)" which I assume contains a call to the "connect" function. From the error it would seem that you are passing a function with an std::string parameter which is not supported in VS2013 (unbound parameters require VS2015 Update 2).

But since you are saying that it also occurs in the examples there might be something else wrong. Could you show the errors that you get when you compile e.g. the "scalable" example?

Maddoggaia

#2
Line 21:    popumMenu->connect("ItemSelected", popupMenuCallback);

and I didn't get any errors with the first or second examples, only the 3rd and 4th, which I did find strange.

all I did was copy and paste the examples you have hosted for 0.7, no alterations, everything is being linked correctly, I went through each example and it was only the last two that threw up the functional has too few arguments.

Errors in Tab example:
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(1149): error C2198: 'void (__cdecl *)(tgui::Gui &,std::string)' : too few arguments for call
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(1137) : see reference to function template instantiation 'void std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>::_Do_call<,0>(std::tuple<>,std::_Arg_idx<0>)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(1137) : see reference to function template instantiation 'void std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>::_Do_call<,0>(std::tuple<>,std::_Arg_idx<0>)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\xrefwrap(283) : see reference to function template instantiation 'void std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>::operator ()<>(void)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\xrefwrap(283) : see reference to function template instantiation 'void std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>::operator ()<>(void)' being compiled
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(228) : see reference to function template instantiation '_Ret std::_Callable_obj<std::_Bind<true,_Ret,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>,false>::_ApplyX<_Rx,>(void)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Rx=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(228) : see reference to function template instantiation '_Ret std::_Callable_obj<std::_Bind<true,_Ret,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>,false>::_ApplyX<_Rx,>(void)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Rx=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(226) : while compiling class template member function 'void std::_Func_impl<_MyWrapper,_Alloc,_Ret,>::_Do_call(void)'
1>          with
1>          [
1>              _Alloc=std::allocator<std::_Func_class<void,>>
1>  ,            _Ret=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(495) : see reference to class template instantiation 'std::_Func_impl<_MyWrapper,_Alloc,_Ret,>' being compiled
1>          with
1>          [
1>              _Alloc=std::allocator<std::_Func_class<void,>>
1>  ,            _Ret=void
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(396) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Do_alloc<_Myimpl,_Ty,_Alloc>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,>>
1>  ,            _Fty=std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(396) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Do_alloc<_Myimpl,_Ty,_Alloc>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,>>
1>  ,            _Fty=std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(385) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset_alloc<_Ty,std::allocator<std::_Func_class<_Ret,>>>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>
1>  ,            _Fty=std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,>>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(385) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset_alloc<_Ty,std::allocator<std::_Func_class<_Ret,>>>(_Fty &&,_Alloc)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>
1>  ,            _Fty=std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>
1>  ,            _Alloc=std::allocator<std::_Func_class<void,>>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(671) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset<_Ty>(_Fty &&)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>
1>  ,            _Fty=std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(671) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset<_Ty>(_Fty &&)' being compiled
1>          with
1>          [
1>              _Ret=void
1>  ,            _Ty=std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>
1>  ,            _Fty=std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>
1>          ]
1>          c:\users\rei\documents\libraries\tgui-0.7\include\tgui\signal.hpp(153) : see reference to function template instantiation 'std::function<void (void)>::function<std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>>(_Fx &&)' being compiled
1>          with
1>          [
1>              _Fx=std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>
1>          ]
1>          c:\users\rei\documents\libraries\tgui-0.7\include\tgui\signal.hpp(153) : see reference to function template instantiation 'std::function<void (void)>::function<std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>>(_Fx &&)' being compiled
1>          with
1>          [
1>              _Fx=std::_Bind<true,void,void (__cdecl *const )(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui> &>
1>          ]
1>          c:\users\rei\documents\libraries\tgui-0.7\include\tgui\signal.hpp(152) : while compiling class template member function 'std::function<void (void)> tgui::priv::connector<type,Func,std::reference_wrapper<tgui::Gui>>::connect(Func,size_t,std::reference_wrapper<tgui::Gui>)'
1>          with
1>          [
1>              Func=void (__cdecl *)(tgui::Gui &,std::string)
1>          ]
1>          c:\users\rei\documents\libraries\tgui-0.7\include\tgui\signal.hpp(240) : see reference to function template instantiation 'std::function<void (void)> tgui::priv::connector<type,Func,std::reference_wrapper<tgui::Gui>>::connect(Func,size_t,std::reference_wrapper<tgui::Gui>)' being compiled
1>          with
1>          [
1>              Func=void (__cdecl *)(tgui::Gui &,std::string)
1>          ]
1>          c:\users\rei\documents\libraries\tgui-0.7\include\tgui\signal.hpp(240) : see reference to class template instantiation 'tgui::priv::connector<type,Func,std::reference_wrapper<tgui::Gui>>' being compiled
1>          with
1>          [
1>              Func=void (__cdecl *)(tgui::Gui &,std::string)
1>          ]
1>          c:\users\rei\documents\libraries\tgui-0.7\include\tgui\signal.hpp(354) : see reference to function template instantiation 'void tgui::Signal::connect<void(__cdecl *)(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui>>(unsigned int,Func,std::reference_wrapper<tgui::Gui>)' being compiled
1>          with
1>          [
1>              Func=void (__cdecl *)(tgui::Gui &,std::string)
1>          ]
1>          c:\users\rei\documents\projects\sfml projects\sfmltgui\sfmltgui\main.cpp(44) : see reference to function template instantiation 'unsigned int tgui::SignalWidgetBase::connect<void(__cdecl *)(tgui::Gui &,std::string),std::reference_wrapper<tgui::Gui>>(const std::string &,Func,std::reference_wrapper<tgui::Gui>)' being compiled
1>          with
1>          [
1>              Func=void (__cdecl *)(tgui::Gui &,std::string)
1>          ]


Above Line 44:    tabs->connect("TabSelected", onTabSelected, std::ref(gui));

texus

Ah you are using the example on the website, I though you were trying to compile the ones in the examples folder the comes with tgui (which I have just tested and build successfully).

Apparently I have used unbound parameters in the online examples. This feature relies on expression SFINAE which is already supported since 2013 in gcc, but Visual Studio has only added enough support for it less than 2 months ago in VS2015.

What basically doesn't work in VS2013 is this:
Code (cpp) Select
void func(std::string s);
widget->connect("pressed", func); // value for s is not provided anywhere!


It only works when binding the value yourself:
Code (cpp) Select
void func(std::string s);
widget->connect("pressed", func, "ValueOfParameter");


You should check the connectEx function if you need to get e.g. the value of the button as parameter to the function in VS2013.

Maddoggaia

Thank you very much, both examples compiled, though the pop up example didn't display anything (though since it ran it's all good).

Now to play about with it :D