Domanda

From the "man" pages it looks like inet_ntop returns a string (const char*) which should be alright when comparing to NULL. However, in my program I get a compiler warning at the first line in this code block that says:

warning: comparison between pointer and integer

. Assuming the correct parameters are being passed in, is there something wrong with this:

    if(inet_ntop(address->sa_family, numericAddress, addrBuffer, sizeof(addrBuffer)) == NULL)
    {
        fputs("invalid address", stream);
    }

Unfortunately I can't distinguish which one it sees as a pointer and which one it sees as an integer. Thanks in advance!

È stato utile?

Soluzione

Have you included the "arpa/inet.h" file?

The "arpa/inet.h" contains inet_ntop declarations. If you do not include it, the compiler will assue inet_ntop returns an int.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top