문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top