This question already has answers here:
Weird compiler error: Cannot convert parameter from 'int' to 'int &&'
(4 answers)
Closed 9 years ago.
Today I wanted to try to bring my project from visual c++ 2010 to visual c++ 2013.
I get this error in visual c++ 2013 which I did not get when compiling with 2010 version.
//somewhere in the SimpleObject_list class
std::unordered_map<std::string, SimpleObject *> Object_list;
//method which is giving me the error
void SimpleObject_list::Add(const char *Object_name, SimpleObject * Object_pointer){
cout << "SimpleObject listed as: " << Object_name << endl;
Object_list.insert(std::make_pair<std::string,SimpleObject *>(Object_name, Object_pointer));
}
the error is:
error C2664: 'std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char>>,SimpleObject *> std::make_pair<std::string,SimpleObject*>(_Ty1 &&,_Ty2 &&)' : cannot convert argument 2 from 'SimpleObject *' to 'SimpleObject *&&'
what am I doing wrong? Why I did not get any error in vc++ 2010?
Thanks
Change
Object_list.insert(std::make_pair<std::string,SimpleObject *>(Object_name, Object_pointer));
to
Object_list.insert(std::make_pair(Object_name, Object_pointer));
Related
The following code snippet
#include "uWS/uWS.h"
int main()
{
uWS::Hub h;
h.onConnection([&h](uWS::WebSocket<uWS::SERVER> *ws, uWS::HttpRequest req) {
std::cout << "Connected!!!" << std::endl;
});
h.run();
}
Generates the errors
Severity Code Description Project File Line Suppression State Error
(active) E0304 no instance of overloaded function
"uWS::Hub::onConnection" matches the argument
list pid c:\Users\R\src\main.cpp 6 Error C2664 'void
uWS::Group<false>::onConnection(std::function<void
(uWS::WebSocket<false>,uWS::HttpRequest)>)': cannot convert argument 1
from 'main::<lambda_1afdd040d2f03ded23f0c636dc85475d>' to
'std::function<void
(uWS::WebSocket<true>,uWS::HttpRequest)>' pid c:\users\r\src\main.cpp 8
When built in Visual Studio 2017 IDE using Windows SDK Version 10.0.15063.0,
where "uWS/uWS.h" contains the tiny web sockets definitions
What could be the problem?
From the error message, it looks like the onConnection function expects a function which takes a uws::WebSocket but your lambda function accepts a uws::WebSocket* instead.
This question already has answers here:
constexpr not compiling in VC2013
(4 answers)
Closed 9 years ago.
Please help me with this error.
I am trying to make a sample that explains constexpr keyword in c++. I am using Visual Studio 2013.
Following is the code of my cpp file.
#include <iostream>
#include <stdexcept>
const int sampleconstant = 5;
constexpr int constTest(void)
{
return sampleconstant;
}
int main()
{
std::cout << constTest();
getchar();
return 0;
}
This shows compile time error as follows:
Error 1 error C2144: syntax error : 'int' should be preceded by ';'
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
I may be doing something silly here. But really can't figure out this error. Code looks ok to me. If any one can help me with error please help.
As already told you, it is not supported on VS.
You can see at this link a list of featured supported by the compilers: http://wiki.apache.org/stdcxx/C++0xCompilerSupport
I am writing an x64 DLL using Visual Studio 2008.
The compiler error
error C2664: 'imgGrab' : cannot convert parameter 2 from 'Int8 **' to 'void **'
occurs at this line;
Int8* ImaqBuffer;
Int32 err = imgGrab (Sid, &ImaqBuffer, TRUE);
I've managed to get it to compile by doing;
Int32 err = imgGrab (Sid, (void **)&ImaqBuffer, TRUE);
but I think this is wrong. Am I right in thinking this is wrong? If so how do I fix it. I suspect its a compiler setting in Visual Studio because the code compiles ok in the sample project from the manufacturer.
This question already has answers here:
Why am I getting "error: expected '}'" in C++ but not in C?
(3 answers)
Closed 9 years ago.
I have the following code in a header file:
enum {false,true};
and I have my main function in main.c. if I change the extention to main.cpp
I get the following error:
Error C2059: syntax error 'constant'
Im using visual c++, any Idea why`?
true and false are keywords representing constant values in C++. You cannot use them to name things such as enum values.
As an example, the following would compile
enum { false_, true_ };
int main() {}
false and true are reserve words in C++. You can't redefine it as variable.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
std::to_string - more than instance of overloaded function matches the argument list
#include <string>
int main()
{
double randDouble = 1245.432;
std::wstring stringDouble = std::to_wstring(randDouble);
}
When I compile this in Visual Studio 2010 I get this error
Error 1 error C2668: 'std::to_wstring' : ambiguous call to overloaded
function 6
1> error C2668:
'std::to_string' : ambiguous call to overloaded function
1> d:\program files (x86)\microsoft visual studio
10.0\vc\include\string(688): could be 'std::string std::to_string(long double)'
1> d:\program files (x86)\microsoft visual studio
10.0\vc\include\string(680): or 'std::string std::to_string(_ULonglong)'
1> d:\program files
(x86)\microsoft visual studio 10.0\vc\include\string(672): or
'std::string std::to_string(_Longlong)'
Can someone please explain to me why the compiler is confused and what am I doing wrong?
This was a bug in Visual C++ 2010. It has been fixed in Visual C++ 2012.