Forum Discussion
Altera_Forum
Honored Contributor
15 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...
Altera_Forum
Honored Contributor
15 years agoThere is a typedef at the very beginning of the code making SSSConn visible as a type (alias 'struct SSS_SOCKET').
If you reformat the source a bit it becomes beter visible
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; Most often we first see the declaration of the structure, followed by the typedef statement.
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 */
} ;
typedef struct SSS_SOCKET SSSConn ;
The first code snippet does the two in one go.