Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strings and client call replies #177

Open
EvyEh opened this issue Dec 14, 2017 · 11 comments
Open

Strings and client call replies #177

EvyEh opened this issue Dec 14, 2017 · 11 comments
Labels

Comments

@EvyEh
Copy link

EvyEh commented Dec 14, 2017

Hello again,

I am having issues with the client getting results from the server. The function it is calling is an std::string function, and my reply call looks like this:

reply=logClient.call("getMessage", command+" "+level).as<std::string>();

on the server side, the method is bound like so:
serv.bind("getMessage", getMessage);

When trying to build this, I get build errors.
object_fwd.hpp(66): error C2039: 'value': is not a member of 'clmdep_msgpack::v1::type'
note: see reference to class template instantiation 'clmdep_msgpack::v1::has_as<T>' being compiled 1> with 1> [ 1> T=std::string 1> ]

Clearly, I'm doing something wrong, but I'm not really sure what.

@sztomi
Copy link
Collaborator

sztomi commented Dec 14, 2017

Can you paste the declaration of the getMessage function?

@EvyEh
Copy link
Author

EvyEh commented Dec 14, 2017

std::string getMessage(std::string message)

@EvyEh
Copy link
Author

EvyEh commented Dec 14, 2017

I have also tried the call as std::string reply(logClient.call("getMessage", sendLog(client_id, message, level)).as<std::string>());
based off the echo_client.cc example, and that caused the same errors.

@sztomi
Copy link
Collaborator

sztomi commented Dec 14, 2017

ok, so it is your client that you can't compile, right? Could you post your code, compiler version and complete compiler output?

@EvyEh
Copy link
Author

EvyEh commented Dec 14, 2017

Client code
`// ThalmicClient.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "..\ClientLib\Clientlib.h"

int main() {
std::string command = "";
std::string client_id;
std::string reply;
rpc::client logClient("127.0.0.1", 8080);
std::cout << "Please Enter client id: "<<std::endl;
std::cin >> client_id;

while (true) {
	std::cout << "Enter command:"<<std::endl;
	std::cin >> command;

	if (command == "?") {
		std::cout << "Valid commands are:\nsend <level (info, warning, or error)> <message to be logged>, sends message to log\ndump <level (info, warning, or error)>, outputs log with level specifying minimum level to dump\nclear, clears log\nquit, exits client\n";
	}
	else if (command == "send") {
		std::string level;
		std::string message;
		std::cin >> level;
		std::getline(std::cin, message);
		reply = logClient.call("getMessage", sendLog(client_id, message, level)).as<std::string>();
		
		
	}
	else if (command == "dump") {
		std::string level;
		std::cin >> level;
		if (level == "info" || level == "warning" || level == "error") {
			std::string totalLog = "";
			reply=logClient.call("getMessage", command+" "+level).as<std::string>();
		}
		else {
			std::cout << "Invalid level specified"<<std::endl;
		}

	}
	else if (command == "clear") {
		reply=logClient.call("getMessage", command).as<std::string>();
	}
	else if (command == "quit") {
		break;
	}
	else {
		std::cout << "Invalid command. To see a list of valid commands, enter ?\n";
	}
}

return 0;

}`

client header
`#pragma once

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>
#include
#include
#include <rpc\client.h>`

Client library
`#include "stdafx.h"

std::string sendLog(std::string client_id,std::string Message, std::string level) {
std::string totalMessage = client_id + " " + level + " " + Message;
return totalMessage;

}`

I'm not sure how to check the compiler version, but I'm using Visual Studio 2017 Community, and I think it might be 14.12.25827. The unknown compiler version messages are an artifact from a small bug in Boost.

Complete compiler output:
1>------ Rebuild All started: Project: ClientLib, Configuration: Debug Win32 ------ 2>------ Rebuild All started: Project: Serverlib, Configuration: Debug Win32 ------ 1>stdafx.cpp 2>stdafx.cpp 2>Unknown compiler version - please run the configure tests and report the results 1>Clientlib.cpp 1>ClientLib.vcxproj -> C:\Users\Er\source\repos\ThalmicLogger\Debug\ClientLib.lib 3>------ Rebuild All started: Project: ThalmicClient, Configuration: Debug Win32 ------ 3>stdafx.cpp 2>Serverlib.cpp 2>c:\users\er\source\repos\thalmiclogger\serverlib\serverlib.cpp(17): warning C4018: '<': signed/unsigned mismatch 2>Serverlib.vcxproj -> C:\Users\Er\source\repos\ThalmicLogger\Debug\Serverlib.lib 2>Done building project "Serverlib.vcxproj". 4>------ Rebuild All started: Project: ThalmicServer, Configuration: Debug Win32 ------ 4>stdafx.cpp 4>Unknown compiler version - please run the configure tests and report the results 3>ThalmicClient.cpp 3>c:\users\er\rpclib\include\rpc\msgpack\v1\object_fwd.hpp(66): error C2039: 'value': is not a member of 'clmdep_msgpack::v1::type' 3>c:\users\er\rpclib\include\rpc\msgpack\v1\adaptor\detail\cpp11_define_map.hpp(22): note: see declaration of 'clmdep_msgpack::v1::type' 3>c:\users\er\rpclib\include\rpc\msgpack\v2\object_fwd.hpp(97): note: see reference to class template instantiation 'clmdep_msgpack::v1::has_as<T>' being compiled 3> with 3> [ 3> T=std::string 3> ] 3>c:\users\er\rpclib\include\rpc\msgpack\v1\object.hpp(121): note: see reference to class template instantiation 'clmdep_msgpack::v2::has_as<T>' being compiled 3> with 3> [ 3> T=std::string 3> ] 3>c:\users\er\source\repos\thalmiclogger\thalmicclient\thalmicclient.cpp(30): note: see reference to function template instantiation 'T clmdep_msgpack::v1::object_handle::as<std::string>(void)' being compiled 3> with 3> [ 3> T=std::string 3> ] 3>c:\users\er\rpclib\include\rpc\msgpack\v1\object_fwd.hpp(66): error C2065: 'value': undeclared identifier 3>c:\users\er\rpclib\include\rpc\msgpack\v1\object_fwd.hpp(66): error C2131: expression did not evaluate to a constant 3>c:\users\er\rpclib\include\rpc\msgpack\v1\object_fwd.hpp(66): note: failure was caused by non-constant arguments or reference to a non-constant symbol 3>c:\users\er\rpclib\include\rpc\msgpack\v1\object_fwd.hpp(66): note: see usage of 'value' 3>c:\users\er\rpclib\include\rpc\msgpack\v2\object_fwd.hpp(98): error C2039: 'value': is not a member of 'clmdep_msgpack::v2::type' 3>c:\users\er\rpclib\include\rpc\msgpack\v2\adaptor\detail\cpp11_define_map_decl.hpp(19): note: see declaration of 'clmdep_msgpack::v2::type' 3>c:\users\er\rpclib\include\rpc\msgpack\v2\object_fwd.hpp(98): error C2065: 'value': undeclared identifier 3>c:\users\er\rpclib\include\rpc\msgpack\v2\object_fwd.hpp(98): error C2131: expression did not evaluate to a constant 3>c:\users\er\rpclib\include\rpc\msgpack\v2\object_fwd.hpp(98): note: failure was caused by non-constant arguments or reference to a non-constant symbol 3>c:\users\er\rpclib\include\rpc\msgpack\v2\object_fwd.hpp(98): note: see usage of 'value' 3>c:\users\er\rpclib\include\rpc\msgpack\v1\object.hpp(121): warning C4305: 'specialization': truncation from 'const bool *' to 'bool' 3>c:\users\er\rpclib\include\rpc\msgpack\v1\object.hpp(121): error C2672: 'clmdep_msgpack::v1::object::as': no matching overloaded function found 3>c:\users\er\rpclib\include\rpc\msgpack\v1\object.hpp(121): error C2770: invalid explicit template argument(s) for 'std::enable_if<clmdep_msgpack::v2::has_as<T>::value,T>::type clmdep_msgpack::v1::object::as(void) const' 3>c:\users\er\rpclib\include\rpc\msgpack\v1\object_fwd.hpp(121): note: see declaration of 'clmdep_msgpack::v1::object::as' 4>ThalmicServer.cpp 3>Done building project "ThalmicClient.vcxproj" -- FAILED. 4>ThalmicServer.vcxproj -> C:\Users\Er\source\repos\ThalmicLogger\Debug\ThalmicServer.exe 5>------ Rebuild All started: Project: UnitTests, Configuration: Debug Win32 ------ 5>stdafx.cpp 5>unittest1.cpp 5>Unknown compiler version - please run the configure tests and report the results 5> Creating library C:\Users\Er\source\repos\ThalmicLogger\Debug\UnitTests.lib and object C:\Users\Er\source\repos\ThalmicLogger\Debug\UnitTests.exp 5>UnitTests.vcxproj -> C:\Users\Er\source\repos\ThalmicLogger\Debug\UnitTests.dll ========== Rebuild All: 4 succeeded, 1 failed, 0 skipped ==========

@alternativelook
Copy link

Hello, I am getting the exact same errors.
I am using VS2017 v141, compiler version is 19.12.25830.2
I only get these errors when I want a result from a call() with .as<T>()
For example: std::string result = c.call("echo", input).as<std::string>();

@anti-matter
Copy link

anti-matter commented Jan 16, 2018

Any update on this issue? I cannot use .as() for any type. I get the compiler error "error C2440: 'return': cannot convert from 'wchar_t *' to 'wchar_t *&'" for every type I attempt to return. Anyone find a workaround?

Update:
Here is code that won't compile:

    auto result =_rpcClient->async_call(func_remove_window, processId, reinterpret_cast<UINT_PTR>(hWnd));
    auto hr = result.get().as<HRESULT>();

...with error code: error C2039: 'value': is not a member of 'clmdep_msgpack::v1::type'

@sztomi
Copy link
Collaborator

sztomi commented Jan 16, 2018

I believe this might be related to the msgpack upgrade. Could you try v2.1.1 in your environment? (that's the version before the bundled msgpack was updated).

@anti-matter
Copy link

Thanks, I built 2.1.1 and pointed my project at it. Now I cannot compile anything:

rror C2440: 'return': cannot convert from 'clmdep_msgpack::v1::object_handle' to 'clmdep_msgpack::v1::object_handle'

It complains mostly about missing copy constructors.

@sztomi
Copy link
Collaborator

sztomi commented Jan 16, 2018

You probably need to clear out your previous build and make sure that you are using both the headers and libs for that version.

@anti-matter
Copy link

I figured it out! I went back to v2.2.1 and stepped through the example compiler config and compared each one with my project settings. It turns out that under Compiler->Language I had "Conformance mode" set to "Yes (/permissive-)". Once I set that to "No", it all compiled and worked fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants