所以我的程序不会编译,我认为这是因为我使用了嵌套结构。它说我需要检查我的库包含。问题是,我不知道该写些什么。不管怎样,请帮帮我吧!: D
有三个错误:
> [Linker error] PROJECT.o:PROJECT.c:(.text+0x47a): undefined reference to `place'
collect2: ld returned 1 exit status
[Error] [PROJECT.exe] Error 1 (if this is the only error: please check your library includes)
下面是我的代码:
typedef struct{
int thick, thin;
int reds, bbqs, creams, pestos;
float pepperoni, pork, mball, tuna, chicken, ham, bacon, shrimp;
float mozz, cheddar, ricotta;
float bellpep, redon, tom, olive, pine, mush;
}TOPP;
typedef struct{
char name[128], address[128];
double contact;
int delivered;
}CUSDET;
typedef struct{
int pres;
int qtyordered;
char name[128];
char desc[128];
float price10, price14, price18;
}PIZZA;
PIZZA prem[50]={0,0,' ',' ',0,0,0};
typedef struct{
float total, totalsum;
TOPP myo10[10], myo14[10], myo18[10];
CUSDET cus;
}ORDZ;
ORDZ temp, *pt;
ORDZ order[90], *pol;
TOPP *pm;
CUSDET *pc;
PIZZA *ppm;`
,然后我在这个函数中使用它们:
void cusdetails(){
pc=&temp.cus;
int a=0, a1;
do{
system("cls");
printf("RMR PIZZA - Customer Page.nn");
printf("Welcome to RMR PIZZA!n");
printf("Enter Name: ");
scanf(" %[^n]s", &pc->name);
printf("Enter Address: ");
scanf(" %[^n]s", &pc->address);
printf("Enter Contact Number: ");
scanf("%lf", &pc->contact);
printf("nn Your details are as follows:nn");
printf("Name: %sn", pc->name);
printf("Address: %sn", pc->address);
printf("Contact Number: %0.0lfn", pc->contact);
}while(a==2);
}
您的错误与嵌套结构无关。错误:
Linker error] PROJECT.o:PROJECT.c:(.text+0x47a): undefined reference to `place'
collect2: ld returned 1 exit status
告诉您它找不到上面没有显示的代码中某些部分使用的命令/函数place
。最有可能的是,您已经定义了一个名为place
的函数,并且在定义出现之前在代码中使用了它(或者它是来自其他库(或文件)的函数,您忘记为其包含头文件)。无论哪种方式,你都试图使用place
,链接器告诉你它不知道你在说什么。参考place
显示代码以获得更多帮助。
错误与您的代码无关。
链接器说一个标识符(函数或变量)被声明和使用,但在目标文件中缺失。
如果一个名为place
的全局变量被声明为extern int place;
,并且在代码中没有任何地方是实际的int place;
实例,则可能发生这种情况
对于函数,这意味着函数体没有被编译,或者它驻留在没有链接到可执行文件的库中。