任何人都可以解释为什么以下代码会给出以下警告以及如何解决它?
warning: assignment makes integer from pointer without a cast [enabled by default]
这是代码:
int tcp_socket(void)
{
int s;
if ((s = socket(PF_INET, SOCK_STREAM, 0)) == -1) {
_logf(LOG_DEBUG, "LOG %s:%d (%s) - %s", __FILE__, __LINE__, __func__, "Error creating socket");
return -1;
}
return s;
}
int main(int argc, char **argv)
{
int socket;
socket = tcp_socket;
if(socket == -1) {
_logf(LOG_INFO, "LOG %s:%d (%s) - %s", __FILE__, __LINE__, __func__, "Error creating socket, exiting...");
exit(-1);
}
}