MSVS 2010 returns "error C2064: term does not evaluate to a function taking 2 arguments"

1,210 views
Skip to first unread message

Andryi Sorotskyi

unread,
Feb 20, 2014, 11:16:55 AM2/20/14
to webso...@googlegroups.com
Hello!

I'm developing websocket server usign WebSocket++ under Windows and have following error:
error C2064: term does not evaluate to a function taking 2 arguments c:\_libs\boost\1.55.0\boost\function\function_template.hpp 153
I use websocketpp::config::asio.

Also, after some examinations I found that problem is caused by method start_accept(). When I comment the line where this method is called compilation is successfull.

Shahar Mintz

unread,
Feb 26, 2014, 4:50:34 AM2/26/14
to webso...@googlegroups.com
Also got this exact problem.

I have traced its origin a bit more up to websocketpp\connection.hpp

in constructor:
explicit connection(bool p_is_server, std::string const & ua, alog_type& alog,
        elog_type
& elog, rng_type & rng)
     
: transport_con_type(p_is_server, alog, elog)
     
, m_handle_read_frame(lib::bind(
           
&type::handle_read_frame,
           
this,
            lib
::placeholders::_1,
            lib
::placeholders::_2
       
))
     
, m_write_frame_handler(lib::bind(
           
&type::handle_write_frame,
           
this,
            lib
::placeholders::_1
       
))


From what I was able to understand the problem is with the lib::bind linked up to websocketpp\common\functional.hpp.
In this file there is a block :

#ifdef _WEBSOCKETPP_CPP11_FUNCTIONAL_
   
using std::function;
   
using std::bind;
   
using std::ref;
   
namespace placeholders = std::placeholders;
#else
   
using boost::function;
   
using boost::bind;
   
using boost::ref;
   
namespace placeholders {
       
/// \todo this feels hacky, is there a better way?
       
using ::_1;
       
using ::_2;
   
}
#endif


I don't use C11 but when I commented out the rest, having definitions as if with C11 it complied!
.. but didn't run. 
when trying to execute VS (2013) said it can't open the *.lib file created by the project.

APPRECIATE ANY HELP!

THANKS


בתאריך יום חמישי, 20 בפברואר 2014 18:16:55 UTC+2, מאת Andrew Sorotskyi:

Shahar Mintz

unread,
Feb 26, 2014, 9:34:40 AM2/26/14
to webso...@googlegroups.com
So I Got it working!

The solution I've found relates to what I've wrote before.
Comment out #ifdef _WEBSOCKETPP_CPP11_FUNCTIONAL_
and the whole #else block.

I'm compiling cross platform so I switched #ifdef _WEBSOCKETPP_CPP11_FUNCTIONAL_ with #ifdef WIN32
and now it complies and runs for both windows and linux.

Good Luck,
Shahar

בתאריך יום רביעי, 26 בפברואר 2014 11:50:34 UTC+2, מאת Shahar Mintz:

Peter Thorson

unread,
Feb 26, 2014, 10:07:48 AM2/26/14
to Shahar Mintz, webso...@googlegroups.com
WebSocket++ allows the use of both Boost or the C++11 standard library to satisfy its requirements for memory management and functional support.

Visual Studio and boost::functional do not play well together. Visual Studio 2010 and later support C++11 <functional> and <memory> headers. It is recommended that Visual Studio users enable these two libraries even if they are not using other C++11 features.

Details on how to do that can be found on the manual’s C++11 support details page: http://www.zaphoyd.com/websocketpp/manual/reference/cpp11-support

Basically this solution is similar to what you came up with (enable C++11 functional library on windows) but via built in mechanisms that don’t require editing the library itself.

--
You received this message because you are subscribed to the Google Groups "WebSocket++" group.
To unsubscribe from this group and stop receiving emails from it, send an email to websocketpp...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Stefan L

unread,
Oct 31, 2014, 3:18:37 AM10/31/14
to webso...@googlegroups.com, mintz....@gmail.com
I have the same problem as it is described in the first post. I get the C2064 compiler error.
I have tried it as it is described in the article you have posted (C++11 support details page: http://www.zaphoyd.com/websocketpp/manual/reference/cpp11-support).

The defines are made at the top of my main file:
#define _WEBSOCKETPP_CPP11_THREAD_
#define _WEBSOCKETPP_CPP11_FUNCTIONAL_
#define _WEBSOCKETPP_CPP11_SYSTEM_ERROR_
#define _WEBSOCKETPP_CPP11_RANDOM_DEVICE_
#define _WEBSOCKETPP_CPP11_MEMORY_

I am using VS 2013 and I already use some new functionality of C++11 in my code.

Maybe this is also interesting for you:
Warnung 4 warning C4996: 'boost::asio::basic_socket<Protocol,StreamSocketService>::cancel': By default, this function always fails with operation_not_supported when used on Windows XP, Windows Server 2003, or earlier. Consult documentation for details. g:\websocketpp\websocketpp\transport\asio\security\none.hpp 225
Warnung 1 warning C4996: 'localtime': This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. g:\websocketpp\websocketpp\logger\basic.hpp 123

Would be great if you could support me here to get the stuff running. I would really appreciate to use WebSocket++ in my project since I also use Boost 1.56.

Peter Thorson

unread,
Nov 3, 2014, 10:21:20 AM11/3/14
to Stefan L, webso...@googlegroups.com, mintz....@gmail.com
Hi Stefan,

For the C2064 error on VS2010 I would try not including the _WEBSOCKETPP_CPP11_THREAD_ define. I believe C++11 threading only works on VS2012 and higher. Let me know if this helps.

The localtime issues is a known issue. I pushed a patch for it to the develop branch this morning. If you could help test whether the new patch fixes the localtime warning that would be helpful.

With respect to the cancel warning.. Not all sockets support canceling. It is fine to ignore that warning.

Peter

--
You received this message because you are subscribed to the Google Groups "WebSocket++" group.
To unsubscribe from this group and stop receiving emails from it, send an email to websocketpp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stefan L

unread,
Nov 3, 2014, 1:48:10 PM11/3/14
to webso...@googlegroups.com, stefan....@gmail.com, mintz....@gmail.com
Hi Peter,

I have removed the _WEBSOCKETPP_CPP11_THREAD_ define and now it works with VS2013 - thank you.
I have also added an issue here: https://github.com/zaphoyd/websocketpp/issues/384

I want to mention that the C++11 Support page (http://www.zaphoyd.com/websocketpp/manual/reference/cpp11-support) contains incorrect information, because I have just copied the recommended defines for VS 2013 and it didn't work.

But it is a little bit strange, isn't it? Because I am using VS2013 and I am using C++11 code in my project already. So I would guess that the threading should work with the removed define?

And yes you were right - the localtime issue doesn't occur anymore. But I also get these one:
warning C4018: '<': Conflict between 'signed' and 'unsigned' g:\websocketpp\websocketpp\sha1\sha1.hpp 167

And since I have added the code from your development branch I also get this one:
warning C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' g:\visual studio 2013\vc\include\xutility 2132

Peter Thorson

unread,
Nov 3, 2014, 1:54:22 PM11/3/14
to Stefan L, webso...@googlegroups.com, mintz....@gmail.com
On Nov 3, 2014, at 13:48, Stefan L <stefan....@gmail.com> wrote:

Hi Peter,

I have removed the _WEBSOCKETPP_CPP11_THREAD_ define and now it works with VS2013 - thank you.
I have also added an issue here: https://github.com/zaphoyd/websocketpp/issues/384

I want to mention that the C++11 Support page (http://www.zaphoyd.com/websocketpp/manual/reference/cpp11-support) contains incorrect information, because I have just copied the recommended defines for VS 2013 and it didn't work.

But it is a little bit strange, isn't it? Because I am using VS2013 and I am using C++11 code in my project already. So I would guess that the threading should work with the removed define?

Hmm, perhaps I misread, I thought your subject line said you were using VS2010 which definitely doesn’t support C++11 threading. I also thought that VS2013 did support C++11 threads hence why the docs say to include that. I’ll have to set up an environment to retest those parameters.

And yes you were right - the localtime issue doesn't occur anymore. But I also get these one:
warning C4018: '<': Conflict between 'signed' and 'unsigned' g:\websocketpp\websocketpp\sha1\sha1.hpp 167

This has been fixed locally, it will get pushed sometime today.

And since I have added the code from your development branch I also get this one:
warning C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' g:\visual studio 2013\vc\include\xutility 2132

Does this have an include trace or some other line number closer to my code?

Stefan L

unread,
Nov 3, 2014, 2:15:14 PM11/3/14
to webso...@googlegroups.com, stefan....@gmail.com, mintz....@gmail.com
And since I have added the code from your development branch I also get this one:
warning C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' g:\visual studio 2013\vc\include\xutility 2132

Does this have an include trace or some other line number closer to my code?


I am so sorry - it is not a problem with your code! The source is of this problem is in another library, which I am using and I have just added it this morning. I totally forgot this! Sorry for the wrong information!  

I did a little test now:
  • When I use the sources of the master branch and I don't define _WEBSOCKETPP_CPP11_THREAD_ I get the error C2064: term does not evaluate to a function taking 2 arguments c:\_libs\boost\1.55.0\boost\function\function_template.hpp 153.
  • When I use the sources of the development branch and I don't define _WEBSOCKETPP_CPP11_THREAD_ I get no error.
  • When I use the sources of the development branch and I define _WEBSOCKETPP_CPP11_THREAD_ I get no error too.
So I guess there must be a bug for VS 2013 in connection with the _WEBSOCKETPP_CPP11_THREAD_  define in your current version (0.3.0).

And that you have thought I use VS2010 cause of the headline of this branch is also my fault - I just thought I don't open another thread for the same issue.

Peter Thorson

unread,
Nov 3, 2014, 2:18:50 PM11/3/14
to Stefan L, webso...@googlegroups.com, mintz....@gmail.com
That makes more sense now. It sounds like the dev branch fixed the issue that was originally causing the C2064 error on VS2013?

Other than the signed/unsigned issue, do you have any other build issues with the dev branch and VS2013?

Stefan L

unread,
Nov 3, 2014, 2:23:15 PM11/3/14
to webso...@googlegroups.com, stefan....@gmail.com, mintz....@gmail.com
Yep - it seems so.

No, there are actually no other build issues. :-)
Reply all
Reply to author
Forward
0 new messages