I make the struct type in header file data.h
struct student{
float tutFee;
};
struct employees{
float salary;
};
struct person{
char firstName[10];
char type; //s for student //e for employee
union {
struct student student;
struct employees employ;
}/*EDIT ->*/common;
};
then when i attempt to declare a struct of type person in menu.c file
#include "menu.h"
#include "data.h"
int initateProgram(){
struct person temp;
}
it gives me an error saying
menu.c:25:19: error: storage size of ‘temp’ isn’t known
Which leads me to believe that either menu.c for some reason does not have access to data.h or i am declaring the struct wrong any insight is appreciated
EDIT
Added a name to the union in the above code. Still is giving me the error i am compiling it as follows
gcc -o a2 uni_personal.c menu.c
uni_personal.c is the main file which calls the function initateProgram() in menu.c Attempting to declare a struct in either location still gets me an error Thanks for the help so Far
Edit 2
I still get the error but when I simplify the program it goes away so evidently the error is unrelated to this particular code
gcc -C -E menu.c > menu.ithen loadmenu.iin your editor.-std=c99 -pedanticit warns that unnamed unions are nonstandard.