• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Warning on compile

Zombiegod

Active Member
Joined
Oct 22, 2009
Messages
198
Solutions
1
Reaction score
25
so when i compile i keep getting this warning, it compiles and runs just fine, but concerns me.

1>..\src\house.cpp(100): warning C4189: 'db1': local variable is initialized but not referenced
 
You didn't share the function that warning references, and the identifier db1 is not present in the current TFS Github or my old 36-40 era sources. Taking a wild guess it's related to this?

C++:
Database* db1 = Database::getInstance();
std::ostringstream query1;
query1 << "SELECT `account_id` FROM `players` WHERE `id` = " << guid;
DBResult_ptr result = db1->storeQuery(query1.str());
ownerAcc = result->getNumber<uint32_t>("account_id");


In that case, the issue is the compiler is having difficult recognizing the member access operator as actually referencing db1, so it thinks db1 is not doing anything and should be removed. That's clearly not the case, so you can safely ignore this warning.

You could also get experimental and try DBResult_ptr result = (*db1).storeQuery(query1.str()); and if that doesn't shut it up you could go full explicit by dropping that line 1 entirely and using DBResult_ptr result = Database::getInstance().storeQuery(query1.str()); for line 4.

But I'd just ignore it. 😪
 
You didn't share the function that warning references, and the identifier db1 is not present in the current TFS Github or my old 36-40 era sources. Taking a wild guess it's related to this?

C++:
Database* db1 = Database::getInstance();
std::ostringstream query1;
query1 << "SELECT `account_id` FROM `players` WHERE `id` = " << guid;
DBResult_ptr result = db1->storeQuery(query1.str());
ownerAcc = result->getNumber<uint32_t>("account_id");


In that case, the issue is the compiler is having difficult recognizing the member access operator as actually referencing db1, so it thinks db1 is not doing anything and should be removed. That's clearly not the case, so you can safely ignore this warning.

You could also get experimental and try DBResult_ptr result = (*db1).storeQuery(query1.str()); and if that doesn't shut it up you could go full explicit by dropping that line 1 entirely and using DBResult_ptr result = Database::getInstance().storeQuery(query1.str()); for line 4.

But I'd just ignore it. 😪
Oops i forgot i made this post, never thought someone would reply either tbh, ty for the reply. I figured out the cause when working on my latest issue (so not to long ago)

simply put i needed to change a bit of code so that the second line here

C++:
DBResult_ptr result = db1->storeQuery(query1.str());

Would fully be read, i think it was just a minor version code correction of "db1.storequery" to "db1->storequery"
Post automatically merged:

in the end i have the fix at the bottom of the related thread for the code here

 
Back
Top