0

I have following simple piece of code, which is a part of ipv6 handling module in a big project.

#include <ctype.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/stat.h>

int main(){
  sockaddr_in6_t* pSadrIn6 = (sockaddr_in6_t*) malloc(sizeof sockaddr_in6_t);
  return 0;
}

It gives me following not error:

error: ‘sockaddr_in6_t’ undeclared (first use in this function)

Is there any special library installation or linking that I need to access the library?

Seth Carnegie
  • 73,875
  • 22
  • 181
  • 249
Amit S
  • 1,053
  • 2
  • 9
  • 18

1 Answers1

3

It looks like you copied this code from the Linux IPv6 HOWTO but didn't copy the additional typedefs:

/*
** Type definitions (for convenience).
*/
typedef enum { false = 0, true } boolean;
typedef struct sockaddr_in       sockaddr_in_t;
typedef struct sockaddr_in6      sockaddr_in6_t;

Personally I would just use the types as they are (instead of extra typedefs to avoid typing struct), but whatever

Brendan Shanks
  • 3,141
  • 14
  • 13