In C you declare variables as:
type varname;
or
struct struct_name varname;
So in your case you need:
struct tipc_port * variable;
Question
Below is the sample structure
struct tipc_port {
void *usr_handle;
spinlock_t *lock;
};
Below is the function call which returns a pointer to the above structure
struct tipc_port *tipc_get_port(const u32 ref);
now I want to store this pointer to struct in some variable and this variable would be passed to some other function.
how to declare this variable which would hold the pointer to struct returned by the above function.
Thanks in Advance :)
Solution
In C you declare variables as:
type varname;
or
struct struct_name varname;
So in your case you need:
struct tipc_port * variable;
OTHER TIPS
One way for doing that is to declare your own type :
typedef struct{
void *usr_handle;
spinlock_t *lock;
}tipc_port_t;
And then use it as you may use any other common types :
tipc_port_t* tipc_get_port(const u32 ref);
And on your code :
tipc_port_t *yourStructPointer;
u32 yourRef;
yourStructPointer = tipc_get_port(yourRef);
[...]
Or :
tipc_port_t yourStructPointer;
u32 yourRef;
&yourStructPointer = tipc_get_port(yourRef);
[...]