Reputation: 1151
I am new to C and trying out Tensorflow in C. I could see most of the Structs are incomplete type and I want to write a function where they are intialized. For example, below code is not working.
int main()
{
TF_Status* Status = NULL;
TF_Graph* Graph = NULL;
init(Status);
return 0;
}
void init(TF_Status* Status, TF_Graph* Graph)
{
Status = TF_NewStatus();
Graph = TF_NewGraph();
}
Any idea how can I do this?
Upvotes: 0
Views: 45
Reputation: 75062
Pass pointers to what to modify to functions to let functions modify them.
void init(TF_Status** Status, TF_Graph** Graph);
int main(void)
{
TF_Status* Status = NULL;
TF_Graph* Graph = NULL;
init(&Status, &Graph);
return 0;
}
void init(TF_Status** Status, TF_Graph** Graph)
{
*Status = TF_NewStatus();
*Graph = TF_NewGraph();
}
Upvotes: 5