B
Bill Cunningham
I have written this wrapper function that seems to compile into an
object file just fine.
#include "main.h"
struct addrinfo ad, *adp;
static int stat;
struct addrinfo **ginfo(char *port)
{
memset(&ad, '\0', sizeof ad);
ad.ai_family = AF_INET;
ad.ai_socktype = SOCK_STREAM;
ad.ai_flags = AI_PASSIVE;
if ((stat = getaddrinfo(NULL, port, &ad, &adp)) != 0) {
fprintf(stderr, "Error: %s\n", gai_strerror(stat));
exit(EXIT_FAILURE);
}
return (struct addrinfo **)stat;
}
Just above is the code in question. I had to make this cast to return my
function's return type because stat is an int. I was told that when code is
written right; casts shouldn't be neccesary. Should I make any changes to
this? Is what I just stated about casts correct?
Bill
object file just fine.
#include "main.h"
struct addrinfo ad, *adp;
static int stat;
struct addrinfo **ginfo(char *port)
{
memset(&ad, '\0', sizeof ad);
ad.ai_family = AF_INET;
ad.ai_socktype = SOCK_STREAM;
ad.ai_flags = AI_PASSIVE;
if ((stat = getaddrinfo(NULL, port, &ad, &adp)) != 0) {
fprintf(stderr, "Error: %s\n", gai_strerror(stat));
exit(EXIT_FAILURE);
}
return (struct addrinfo **)stat;
}
Just above is the code in question. I had to make this cast to return my
function's return type because stat is an int. I was told that when code is
written right; casts shouldn't be neccesary. Should I make any changes to
this? Is what I just stated about casts correct?
Bill