#error: ISO C++ forbids comparison between pointer and integer [-fpermissive]

122 messages · Page 1 of 1 (latest)

humble shale
#

hello i got this error and i dont know what to do. I use CodeBlocks IDE(bcs i need it for linux)

there is a code:
void ReplicaManager3::AutoCreateConnectionList( DataStructures::List<RakNetGUID> &participantListIn, DataStructures::List<Connection_RM3*> &participantListOut, WorldId worldId) { for (unsigned int index=0; index < participantListIn.Size(); index++) { if (GetConnectionByGUID(participantListIn[index], worldId)==false) { Connection_RM3 *connection = AllocConnection(rakPeerInterface->GetSystemAddressFromGuid(participantListIn[index]), participantListIn[index]); if (connection) { PushConnection(connection); participantListOut.Push(connection, _FILE_AND_LINE_); } } } }

and the error is there: if (GetConnectionByGUID(participantListIn[index], worldId)==false)

eager flameBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

median summit
#

Could you paste the full error message?

#

Also

#

!code

eager flameBOT
#
How to Format Code on Discord
Markup

```cpp
int main() {}
```

Result
int main() {}
median summit
#

What type does getconnectionbyid return?

humble shale
#

@median summit yeah no problem

C:\Users\BLAH\BLAH\sdks\RakNet\ReplicaManager3.cpp||In member function 'void RakNet::ReplicaManager3::AutoCreateConnectionList(DataStructures::List<RakNet::RakNetGUID>&, DataStructures::List<RakNet::Connection_RM3*>&, RakNet::WorldId)':|
C:\Users\BLAH\BLAH\sdks\RakNet\ReplicaManager3.cpp|131|error: ISO C++ forbids comparison between pointer and integer [-fpermissive]|
||=== Build finished: 1 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|```
humble shale
cedar junco
#

You'll want to find the documentation of the function/look at its source code to figure out what to change that false to. I suspect it returns nullptr on error.

humble shale
#

Aha soo i need to find some documentation

humble shale
#

@cedar junco in RakNet source i found this /// \brief Track a new Connection_RM3 instance /// \details If \a autoCreate is false for SetAutoManageConnections(), then you need this function to add new instances of Connection_RM3 yourself.<BR> /// You don't need to track this pointer yourself, you can get it with GetConnectionAtIndex(), GetConnectionByGUID(), or GetConnectionBySystemAddress().<BR> /// \param[in] newConnection The new connection instance to track. /// \param[in] worldId Used for multiple worlds. World 0 is created automatically by default. See AddWorld() bool PushConnection(RakNet::Connection_RM3 *newConnection, WorldId worldId=0);

#

and

#
{
    if (newConnection==0)
        return false;
    if (GetConnectionByGUID(newConnection->GetRakNetGUID(), worldId))
        return false;
    // Was this intended?
    RakAssert(newConnection->GetRakNetGUID()!=rakPeerInterface->GetMyGUID());
    
    RakAssert(worldsArray[worldId]!=0 && "World not in use");
    RM3World *world = worldsArray[worldId];

    unsigned int index = world->connectionList.GetIndexOf(newConnection);
    if (index==(unsigned int)-1)
    {
        world->connectionList.Push(newConnection,_FILE_AND_LINE_);

        // Send message to validate the connection
        newConnection->SendValidation(rakPeerInterface, worldId);

        Connection_RM3::ConstructionMode constructionMode = newConnection->QueryConstructionMode();
        if (constructionMode==Connection_RM3::QUERY_REPLICA_FOR_CONSTRUCTION || constructionMode==Connection_RM3::QUERY_REPLICA_FOR_CONSTRUCTION_AND_DESTRUCTION)
        {
            unsigned int pushIdx;
            for (pushIdx=0; pushIdx < world->userReplicaList.Size(); pushIdx++)
                newConnection->OnLocalReference(world->userReplicaList[pushIdx], this);
        }
    }
    return true;
}```
#
{
    RakAssert(worldsArray[worldId]!=0 && "World not in use");
    RM3World *world = worldsArray[worldId];

    unsigned int index;
    for (index=0; index < world->connectionList.Size(); index++)
    {
        if (world->connectionList[index]->GetRakNetGUID()==guid)
        {
            return world->connectionList[index];
        }
    }
    return 0;
}```
#
        {
            Connection_RM3 *connection = GetConnectionByGUID(packet->guid, incomingWorldId);
            if (connection && connection->isValidated==false)
            {
                // This connection is now confirmed bidirectional
                connection->isValidated=true;
                // Reply back on validation
                connection->SendValidation(rakPeerInterface,incomingWorldId);
            }
        }
    }```
#
    if (connection==0)
    {
        // Almost certainly a bug
        RakAssert("Got OnConstruction but no connection yet" && 0);
        return RR_CONTINUE_PROCESSING;
    } ```
#
    if (connection==0)
        return RR_CONTINUE_PROCESSING;
    if (connection->groupConstructionAndSerialize)
    {
        connection->downloadGroup.Push(packet, __FILE__, __LINE__);
        return RR_STOP_PROCESSING;
    }```
#
    if (connection==0)
        return RR_CONTINUE_PROCESSING;
    if (connection->QueryGroupDownloadMessages() &&
        // ID_DOWNLOAD_STARTED will be processed twice, being processed the second time once ID_DOWNLOAD_COMPLETE arrives.
        // However, the second time groupConstructionAndSerialize will be set to true so it won't be processed a third time
        connection->groupConstructionAndSerialize==false
        )```
#
    if (connection==0)
        return RR_CONTINUE_PROCESSING;```
#

is there some code we need ?

#

thats all i found

#

@cedar junco

#

and this Connection_RM3* GetConnectionByGUID(RakNetGUID guid, WorldId worldId=0) const;

#

thats all i think

cedar junco
humble shale
humble shale
#

no

cedar junco
#

Who did

humble shale
#

its SDK

#

RakNet

cedar junco
#

Why are you trying to compile it? And how are you compiling it?

#

Did you put a #include "raknet.h" or something in your own project?

humble shale
#

hey man its SDK for my code i need it bcs i create something like SAMP(samp using RakNet too) but for Czech game Mafia the city of Lost Heaven

cedar junco
#

So how are you using it in your code? With something like #include "raknet.h"?

humble shale
#

i dont know how to explain it

cedar junco
#

Well try your best

#

What code editor are you using, are you on Windows, do you use a Makefile or cmake?

humble shale
#

RakNet is folder in my SDKs with so many files so somewhere is just simply ../sdks/Raknet/ thats all

humble shale
cedar junco
#

Right, and are you making use of raknet anywhere yet in your project, or did you just try to add raknet to your program right now?

#

Also, is it your own project, or are you trying to compile other people's code?

humble shale
#

we started doing this project 2 I did only something that I understood but I don't understand networking etc. that's why the other one did it (we are no longer in contact and he left the whole project to me) and that project is based on another open source project and I think this is from that previous project

cedar junco
# humble shale RakNet was already here

Alright, so inside of your game (and not inside of the raknet library header), try to find where you are currently making use of raknet's functions. Do you see a #include "raknet.h" at the top of one of those files?

humble shale
#

raknet.h not exist

#

im trying to find main file for raknet

#

there is RakNet.vcproj

#

<Add directory="../sdks/RakNet" />

humble shale
cedar junco
#

Are you allowed to send a github link to your code here so I can help out?

humble shale
cedar junco
#

Do you have git working though?

humble shale
#

maybe we can call and i can share the screen

#

yes

cedar junco
#

Nah, I want to look through the code leisurely

cedar junco
humble shale
#

it just say ERROR uploading

cedar junco
#

Show that terminal output

#

Getting it on github should be your new #1 priority

humble shale
#

at first i dont know if i want to share my almost 3 years work with someone who i dont know thinkeyes

cedar junco
#

I mean that should be an easy decision to make right, either you do or you don't?

#

I am not going to beg for it or something

#

It's fine if you don't, it just makes it harder for others to help

humble shale
#

i know but as like i say its 6,3 GB code from my 3 years work

cedar junco
#

How come you are getting this compilation error now?

humble shale
#

and Visual Studio does not show this problem but Code Blocks does

cedar junco
#

Okay, so since the compilation error you posted seems to be in the actual raknet library, you can add the compilation flag -fno-permissive to get rid of this error. Ideally you only use this flag when compiling the raknet library and not when compiling your own code.

#

Or you can use a #pragma to ignore the warning for that specific line

humble shale
cedar junco
humble shale
#

i can not use #pragma bcs its error and its work only for warnings or no ?

cedar junco
#

Ohh, no it still works because if you suppress the warning it never gets to turn into an error

humble shale
#

ahaaaaaa

cedar junco
#

But I recommend just adding -fno-permissive if you want to quickly fix the issue

humble shale
#

where add this?

#

bcs like i said iam using Code Blocks for first

cedar junco
humble shale
#

makefile and tesla files

cedar junco
#

Tesla? Never heard of that before

humble shale
cedar junco
#

I think you can ignore those files for compilation. Send your Makefile

humble shale
#

Tesla.cbp is for CodeBlocks

#

its like .sln

#

i have Makefile now what

cedar junco
#

Send it by dragging it on top of Discord

humble shale
#

can you just tell me what i need to paste in code ? please

humble shale
#

I didn't do anything but I have more errors there

cedar junco
#

Did you change anything in this file?

humble shale
#

no

#

its file somewhere in pc

#

in program files

cedar junco
#

Were you at least able to fix the original raknet error using that flag -fno-permissive?

humble shale
#

no

cedar junco
cedar junco
#

? What file is that

humble shale
humble shale
cedar junco
cedar junco
humble shale
#

i need to compile file for linux bcs the SERVER is will be for public

#

the whole project is Multiplayer for single player game like SAMP like i said so i need windows server(i have it) and linux server(i need it for hostings etc)

humble shale
cedar junco
cedar junco
#

If you send the makefile I can just straight-up tell you where you should, like I said earlier

cedar junco
#

Sure, send it in a DM if you want

humble shale
#

@cedar junco so ?