C++: C2511: Overloaded member function not found. problems when using 'this' - visual-studio-2013

I have this one object that tries to call a function in another class's function. That function looks like this (Belongs to class 'Player' ):
void play(Game *const currentGame, int x, int y);
When I try to call this function from another object (of the Game class) like this :
player->play(this, x, y)
And during compilation I get these errors:
Error 1 error C2061: syntax error : identifier 'Game' c:\users\shaqed\documents\visual studio 2013\projects\exe3\tictactoe.h 24 1 Exe3
Error 3 error C2511: 'void Player::play(Game *const ,int,int)' : overloaded member function not found in 'Player' c:\users\shaqed\documents\visual studio 2013\projects\exe3\tictactoe.cpp 40 1 Exe3
Error 4 error C2660: 'Player::play' : function does not take 3 arguments c:\users\shaqed\documents\visual studio 2013\projects\exe3\tictactoe.cpp 158 1 Exe3
I came from Java, so maybe I lack some of the core principles about pointers and reference, however I could figure out why there's a type mismatch in here.
Thanks in advance

I have repeated your problem with the same compile errors. I think you have forgotten to add at the end of your method the body. Like:
void play(const Game *currentGame, int x, int y){}

Related

'RedisCluster' has no member named 'get_shards_pool'

I am trying to build DeathStarBench (https://github.com/delimitrou/DeathStarBench), however, I am getting the following error:
In file included from /social-network-microservices/src/HomeTimelineService/HomeTimelineService.cpp:15:0:
/social-network-microservices/src/HomeTimelineService/HomeTimelineHandler.h: In member function 'virtual void social_network::HomeTimelineHandler::WriteHomeTimeline(int64_t, int64_t, int64_t, int64_t, const std::vector&, const std::mapstd::__cxx11::basic_string<char, std::__cxx11::basic_string >&)':
/social-network-microservices/src/HomeTimelineService/HomeTimelineHandler.h:129:55: error: 'class sw::redis::RedisCluster' has no member named 'get_shards_pool'
auto *shards_pool = _redis_cluster_client_pool->get_shards_pool();
I don't know anything about Redis. However, I googled the error message and couldn't find anything related to this. Any suggestions on what might be the problem?

Errors with find_if() & mem_fun1()

I have code that worked well in Visual C++ 6.0. Now I need to get it working in VS 2017. I have some error messages when I compile, and I'm really not sure how to fix it. Here's the code:
class CTagDB : public CObject
{
...
bool SameTag (const CTagDB *TagDB) { return TagDB && *this == *TagDB; }
...
}
class CTagsDB : public CObject
{
...
std::vector<CTagDB*> m_Tags;
...
}
bool CTagsDB::IsDup(const CTagDB *TagDB) const
{
return std::find_if(m_Tags.begin(), m_Tags.end(),
std::bind2nd(std::mem_fun1(CTagDB::SameTag),
TagDB)) != m_Tags.end();
}
For this code I get the following errors:
error C2039: 'mem_fun1': is not a member of 'std' C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\map(16):
note: see declaration of 'std'
error C3867: 'CTagDB::SameTag': non-standard syntax; use '&' to create a pointer to member
error C3861: 'mem_fun1': identifier not found
error C2672: 'std::find_if': no matching overloaded function found
error C2780: '_InIt std::find_if(_InIt,_InIt,_Pr)': expects 3 arguments - 2 provided
Seeing the methods begin() & end(), I suspect that there is a problem with the way the vectors are being used, because originally the code was written without iterators. But this fragment of code is so clever as to be very difficult to decipher, let alone maintain (by me).
Can anyone help me figure out what is going on here and how to fix it?

Pebble C TupletCString compile error

I have an issue compiling my pebble watchapp. I am trying to send strings to the Pebbl eJS script on the phone lihe this:
Tuplet password_tuple = TupletCString(PASSWORD_KEY, password_str);
Tuplet email_tuple = TupletCString(EMAIL_KEY, email_str);
The compiler error is: (they both error out like this, this is just one of the lines of output below)
./src/app_test.c:84:25: error: the address of 'email_str' will always evaluate as 'true' [-Werror=address]
email_str and password_str are defined at the top of the program, like this:
static char email_str[30];
static char password_str[30];
#define PASSWORD_PKEY (int32_t)21
#define EMAIL_PKEY (int32_t)20
Does anyone notice anything wrong with this?
#ismail-badawi answer is very correct.
Pebble now recommends that you use dict_write_cstring.
dict_write_cstring(&iter, SOME_STRING_KEY, string);
Well it's certainly not obvious, but it turns out it's because TupletCString is a macro, and it'll expand to an expression that contains email_str ? strlen(email_str) + 1 : 0 as a subexpression, and this is what causes the error, because email_str can't be null and so the comparison isn't doing anything.
I found this thread on the Pebble forums with an explanation. The suggested fix is to define your own macro that doesn't have a conditional, e.g.
#define MyTupletCString(_key, _cstring) \
((const Tuplet) { .type = TUPLE_CSTRING, .key = _key, .cstring = { .data = _cstring, .length = strlen(_cstring) + 1 }})

CLR IL-significance of square bracket on .locals init

I am trying to generate a dynamic assembly using Reflection & Emit in .NET. I am getting an error, "Common Language Runtime detected an invalid program." I created another program which has the functionality I want using hard-coded types. The functionality I am trying to write will ultimately use dynamic types, but I can use ILDasm to see the IL I need to generate. I am comparing the IL I am generating with the IL which the compiler generates. In the .locals init declaration of one method I see there is an extra item in the compiler-generated code,
compiler-generated:
.locals init ([0] class [System.Core]System.Linq.Expressions.ParameterExpression CS$0$0000,
[1] class [System.Core]System.Linq.Expressions.ParameterExpression[] CS$0$0001)
mine:
.locals init (class [System.Core]System.Linq.Expressions.ParameterExpression V_0,
class [System.Core]System.Linq.Expressions.ParameterExpression[] V_1)
I don't understand the significance of the "[0]" and "[1]" in the compiler-generated code. Can anyone tell me what it means?
As a more general question, I can follow most ILDasm output without too much trouble. But every so often I run across a problematic expression. For instance, in this line from ILDasm
callvirt instance class [EntityFramework]System.Data.Entity.ModelConfiguration.EntityTypeConfiguration`1<!!0> [EntityFramework]System.Data.Entity.DbModelBuilder::Entity<class DynamicEdmxTrial.HardFooAsset>()
the "!!0" probably refers to the generic type of the Entity<>, but I don't know for sure, and I wonder if there is a key to ILDasm output that would explain its more obscure output to me.
The specification is freely available here. It takes a little getting used to, but most details are easily found once you figure out the structure.
!! is listed in II.7.1 Types:
Type ::= | Description | Clause
‘!’ Int32 | Generic parameter in a type definition, | §II.9.1
| accessed by index from 0 |
| ‘!!’ Int32 | Generic parameter in a method | §II.9.2
| definition, accessed by index from 0 |
...
In other words, inside a method that C# would call f<T, U>(), !!0 would be T, and !!1 would be U.
However, the [0] is a good question. The spec does not seem to address it. The .locals directive is described in II.15.4.1.3 The .locals directive, which lists the syntax as
MethodBodyItem ::= ...
| .locals [ init ] ‘(’ LocalsSignature ‘)’
LocalsSignature ::= Local [ ‘,’ Local ]*
Local ::= Type [ Id ]
There is nothing that seems to allow [0] there unless it is part of a Type, and Type does not allow anything starting with [ either. My guess is that this is an undocumented peculiarity specific to Microsoft's implementation, intended to help the human reader see that location 0 is local variable CS$0$0000, for when the generated instructions access local variables by index.
Experimenting with ILAsm shows that this is exactly what it means. Taking a simple C# program:
static class Program {
static void Main() {
int i = 0, j = 1;
}
}
and compiling and then disassembling it (csc test.cs && ildasm /text test.exe >test.il) shows:
....
.locals init (int32 V_0,
int32 V_1)
IL_0000: nop
IL_0001: ldc.i4.0
IL_0002: stloc.0
IL_0003: ldc.i4.1
IL_0004: stloc.1
IL_0005: ret
....
Modifying the .locals to
.locals init ([0] int32 V_0, [0] int32 V_1)
gives a useful warning message:
test.il(41) : warning : Local var slot 0 is in use
And indeed, declaring variables of different types, then reordering them using [2], [1], [0], assembling and immediately disassembling the result, shows that the variables got reordered.

Compiling OpenMCU in Linux (Fedora12)

I am tring to compile OpenMCU in fedora 12. Since the orignal project was compiled in VC++, it has some compatiility issues with gcc.
I am using gcc 4.4.4 and febora 12.
The error shows somehting like this.
In file included from mcu.h:84,
from main.cxx:56:
filemembers.h:123: error: ISO C++ forbids declaration of ‘deque’ with no type
filemembers.h:123: error: typedef name may not be a nested-name-specifier
filemembers.h:123: error: expected ‘;’ before ‘<’ token
filemembers.h:124: error: ISO C++ forbids declaration of ‘FilenameList’ with no type
filemembers.h:124: error: expected ‘,’ or ‘...’ before ‘&’ token
In file included from mcu.h:84,
from main.cxx:56:
filemembers.h:149: error: ‘FilenameList’ does not name a type
make: *** [obj_linux_x86_r/main.o] Error 1
when checked in the source code of that perticular file it was something like this...
class ConferenceFileMember : public ConferenceMember
{
PCLASSINFO(ConferenceFileMember, ConferenceMember);
public:
ConferenceFileMember(Conference * conference, const PFilePath & _fn, PFile::OpenMode mode);
*typedef std::deque<PFilePath> FilenameList; //Line 123..*
ConferenceFileMember(Conference * conference, const FilenameList & _fns, PFile::OpenMode mode);
~ConferenceFileMember();
void Unlisten();
Seems to be a simple syntax issue. Can someone help me in this regards?
Thanx in advance..
Looks like std::deque is not defined. Did you #include <deque>?

Resources