Altera_Forum
Honored Contributor
14 years agoPassing Structures into Functions
Hi Guys,
question I need some clarification on passing structures into functions. in what i'll outline below, i don't understand why the function prototypes are as they are. This is how i understand it, but if i say something wrong please correct me. example that confuses me What i've got is the Niche stack with the below structure.typedef
struct SSS_SOCKET {
enum { READY, COMPLETE, CLOSE } state;
int fd;
int close;
INT8U rx_buffer;
INT8U *rx_rd_pos; /* position we've read up to */
INT8U *rx_wr_pos; /* position we've written up to */
} SSSConn;
This says to me "define a structure type SSS_Socket, and create an instance called SSSConn.". Now functions that use this have their prototypes as: void SSS_handle_receive(SSSConn* conn) and function call appears as: SSS_handle_receive(&conn) What i don't understand is why is an instance of a structure being used instead of the type itself i would have thought a prototype would be: void SSS_handle_receive(SSS_SOCKET* conn) can someone please explain whats happening here?