c - error: dereferencing pointer to incomplete type -> passing structure to module -
the structure:
#include <gtk/gtk.h> #include "db_interface.h" struct addnewemployee { const gchar *fname; const gchar *lname; }; void new_emp_get_data(gtkwidget *widget, gpointer add_emp_window) { struct addnewemployee n_e_s; //new employee struct <gtk portion removed clean code> n_e_s.fname=gtk_entry_get_text(gtk_entry(first)); n_e_s.lname=gtk_entry_get_text(gtk_entry(last)); db_add_new_emp(&n_e_s); //pass struct db_interface add new employee }
the header file (db_interface.h)
#ifndef db_interface_h #define db_interface_h struct addnewemployee *n_e_s; void db_add_new_emp(struct addnewemployee *n_e_s); #endif
the second module (db_interface.c)
#include <stdio.h> #include "db_interface.h" void db_add_new_emp(struct addnewemployee *n_e_s) { printf("greetings db_interface, %s\n", n_e_s->fname); }
when try compile code using gcc, message "error: dereferencing pointer incomplete type". have tried several different answers found when others posted problems error, have yet find 1 works. copied code in function db_interface.c module original module - 1 containing struct - , worked fine, know problem lies sending structure db_interface.c module.
just move struct addnewemployee
db_interface.h , should compile fine. both .c files need know how struct implemented.
Comments
Post a Comment