User forums > Using Code::Blocks

error: `sockaddr_in' undeclared (first use in this function)

<< < (2/2)

eb:
Hold on...
Consider the code:


--- Code: ---struct group_filter
{
  uint32_t                gf_interface;
  struct sockaddr_storage gf_group;
  uint32_t                gf_fmode;
  uint32_t                gf_numsrc;
  struct sockaddr_storage gf_slist[1];
};

#define GROUP_FILTER_SIZE(numsrc) (sizeof (struct group_filter) \
  - sizeof (struct sockaddr_storage) \
  + (numsrc) * sizeof (struct sockaddr_storage))

/* Structure describing an Internet (IP) socket address. */
#define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
struct sockaddr_in
{
  sa_family_t sin_family; /* Address family */
  in_port_t sin_port; /* Port number */
  struct in_addr sin_addr; /* Internet address */

  /* Pad to size of `struct sockaddr'. */
  unsigned char  __pad[__SOCK_SIZE__ - sizeof(short int)
- sizeof(unsigned short int) - sizeof(struct in_addr)];
};

--- End code ---

CodeBlocks sees group_filter as a symbol but not sockaddr_in.  But if I insert a blank line above "struct sockaddr_in" CodeBlocks sees sockaddr_in and adds it to the 'All local symbols (workspace)' list.

I still get the compile error though. >:(


OH! And "Find declaration of:" finds it now.

MortenMacFly:

--- Quote from: eb on February 04, 2012, 01:06:11 am ---Hold on...
Consider the code:
[...]
CodeBlocks sees group_filter as a symbol but not sockaddr_in.

--- End quote ---
Works fine here. However, as you did not mention anything about your configuration (Platform, version) nobody can help you.

eb:
Platform Win XP 64
version Code Blocks 10.05

Navigation

[0] Message Index

[*] Previous page

Go to full version