I am trying to compile this program but it gives me compile error, even though I have added functions.h
Code of p2_e4 (where the main is):
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stack_fp.h"
#include "node.h"
#include "graph.h"
#include "functions.h"
int stack_node_conections(Stack *s, Stack *s_enteros, Graph *g) {
int nNodes;
int numTotal;
int *ids;
int i=0, j=0;
if (!s || !s_enteros|| !g){
return -1;
}
nNodes = graph_getNnodes(g);
ids = graph_getNodeIds(g);
numTotal = 2 * graph_getNedges(g);
for (i=nNodes-1; i >= 0; i--) {
for (j=nNodes-1; j >= 0; j--) {
if (graph_areConnected(g, ids[i], ids[j]) == TRUE) {
stack_push(s, graph_getNode(g, ids[i]));
stack_push(s_enteros, &ids[i]);
stack_push(s, graph_getNode(g, ids[j]));
stack_push(s_enteros, &ids[j]);
}
else
continue;
}
}
return numTotal;
}
int main(int argc, char** argv){
Stack *s;
Stack *s_enteros;
Graph *g;
if(argc<2){
printf("ERROR. <ejecutable> <archivo>\n");
return -1;
}
g = graph_ini();
if(!g){
return -1;
}
g = read_graph_from_file(argv[1]);
s = stack_ini(destroy_node_function, copy_node_function, print_node_function);
if(!s){
graph_destroy(g);
return-1;
}
s_enteros = stack_ini(destroy_intp_function, copy_intp_function, print_intp_function);
if(!s_enteros){
stack_destroy(s);
graph_destroy(g);
return -1;
}
stack_node_conections(s, s_enteros, g);
printf("Pila de enteros:\n");
stack_print(stdout, s_enteros);
printf("Pila de nodos:\n");
stack_print(stdout, s);
stack_destroy(s_enteros);
stack_destroy(s);
graph_destroy(g);
return 0;
}
Function.h code:
#ifdef FUNCTIONS_H
#define FUNCTIONS_H
void destroy_intp_function(void* e);
void * copy_intp_function(const void* e);
int print_intp_function(FILE * f, const void* e);
void destroy_node_function(void* e);
void * copy_node_function(const void* e);
int print_node_function(FILE * f, const void* e);
#endif