UIP Error field 'p' has incomplete type

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Good day.

 

I master Ethernet on the uIP stack. When using the standard "Hello world" example, an error "field 'p' has incomplete type" occurred.

#ifndef __HELLO_WORLD_H__
#define __HELLO_WORLD_H__

/* Since this file will be included by uip.h, we cannot include uip.h
   here. But we might need to include uipopt.h if we need the u8_t and
   u16_t datatypes. */
#include "uip/uipopt.h"

#include "uip/psock.h"

/* Next, we define the uip_tcp_appstate_t datatype. This is the state
   of our application, and the memory required for this state is
   allocated together with each TCP connection. One application state
   for each TCP connection. */
typedef struct hello_world_state {
    struct psock p; // error 
    char inputbuffer[10];
    char name[40];
} uip_tcp_appstate_t;

/* Finally we define the application function to be called by uIP. */
void hello_world_appcall(void);
#ifndef UIP_APPCALL
#define UIP_APPCALL hello_world_appcall
#endif /* UIP_APPCALL */

void hello_world_init(void);

#endif /* __HELLO_WORLD_H__ */

Please help to deal with the error.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well clearly it's complaining about:

struct psock

so I would follow this back to:

#include "uip/psock.h"

and see what's going on in there.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the file psosk.h I have such a struct

 


/**
 * The representation of a protosocket.
 *
 * The protosocket structrure is an opaque structure with no user-visible
 * elements.
 */
struct psock {
	struct pt pt, psockpt; /* Protothreads - one that's using the psock
			    functions, and one that runs inside the
			    psock functions. */
	const u8_t *sendptr;   /* Pointer to the next data to be sent. */
	u8_t *readptr;         /* Pointer to the next data to be read. */

	u8_t *bufptr;          /* Pointer to the buffer used for buffering
			    incoming data. */

	u16_t sendlen;         /* The number of bytes left to be sent. */
	u16_t readlen;         /* The number of bytes left to be read. */

	struct psock_buf buf;  /* The structure holding the state of the
			    input buffer. */
	unsigned int bufsize;  /* The size of the input buffer. */

	unsigned char state;   /* The state of the protosocket. */
};

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Microsoft (yes them) helpfully have this to say about "incomplete type":

 

https://msdn.microsoft.com/en-us...

 

An incomplete type is a type that describes an identifier but lacks information needed to determine the size of the identifier. An "incomplete type" can be:

  • A structure type whose members you have not yet specified.

I notice the code you quote has:

	struct pt pt, psockpt; /* Protothreads - one that's using the psock
			    functions, and one that runs inside the
			    psock functions. */

and

	struct psock_buf buf;  /* The structure holding the state of the
			    input buffer. */

So clearly the compiler will need to have seen the declaration (and hence know the size of) "struct pt" and "struct psock_buf". Are you including all the headers necessary?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 Are you including all the headers necessary?

Да. 

Last Edited: Mon. Jan 29, 2018 - 10:52 AM