コードを C でコンパイルすると、「エラー LNK2001: 未解決の外部シンボル _staff」というエラーと、未解決の外部に関するエラーが発生します。私のstaff配列には外部ファイルが必要だと思われているようですが、それはPersons(2つのタイプのUnion)を保持するための単なる配列です。問題を解決するにはどうすればよいですか? 私のコードの冒頭は以下です。
#include <stdio.h>
#include <string.h>
//employee struct
typedef struct {
//...
} Employee;
//Manager struct inheriting from employee struct
typedef struct {
Employee employee;
int bonus;
} Manager;
//union of manager and employee
typedef union{
Employee e;
Manager m;
} Person;
//functions
Employee newEmployee(char n[], ...);
Manager newManager(...);
double getManagerSalary(Manager man);
Manager boss;
Employee harry ;
Employee tommy;
Person staff[];
//main code
int main(void)
{
boss = newManager(...);
harry = newEmployee(...);
tommy = newEmployee(...);
staff[3];
staff[0].m = boss;
staff[1].e = harry;
staff[2].e = tommy;
...
}
Employee newEmployee(char n[], double s, int year, int month, int day)
{
...
}