I’m using a library written in C and the library provides headers which only use void*. The library is used to create a kind of graph, which is stored inside the C data-base. The headers return void* to the nodes in the graph. To create the graph, I need to parse a stack of lets say node names. In parallel to the stack of node names, I need to maintain a stack void* for the nodes. I have something like this:
std::stack < void* > nodeStack;
while (!nodeNameStack.empty()) {
// check if nodeNamestack.front() meets some criteria
nodeStack.push(C_API_To_Create_Node(nodeNameStack.pop()));
// Do some processing
// check if nodeStack.size() >= 2
void *node1 = nodeStack.pop()
void *node2 = nodeStack.pop()
// Above line issues error saying void value not ignored as it ought to be..
I’m not sure what the issue is, as we guarantee nodeStack size is atleast 2. I would appreciate any suggestions to overcome this error..
std::stack::pop()doesn’t return the element removed. You have to read it withtop()before popping it.