c程序的未定义引用Clion

c程序的未定义引用Clion,c,clion,undefined-reference,C,Clion,Undefined Reference,我使用的是CLion,但当我尝试运行struct.c文件时,它总是给我: 在函数“main”中™: (文件位置)警告:传递参数1“displayAllEmployees”™ 来自不兼容的指针类型[-Wincompatible指针类型] displayAllEmployees(employees,cnt); ^~~~~~~~~ 在文件中包括从 注:应为–PERSON**{aka struct PERSON**}™ 但参数的类型是“PERSON*{aka

我使用的是CLion,但当我尝试运行struct.c文件时,它总是给我:

在函数“main”中™:

(文件位置)警告:传递参数1“displayAllEmployees”™ 来自不兼容的指针类型[-Wincompatible指针类型]

 displayAllEmployees(employees,cnt);
                     ^~~~~~~~~
在文件中包括从

注:应为–PERSON**{aka struct PERSON**}™ 但参数的类型是“PERSON*{aka struct PERSON*}”™

无效显示所有员工(个人*员工[],国际员工人数)

[100%]链接C可执行结构

在函数“main”中:

对“addEmployee”的未定义引用

对“displayEmployee”的未定义引用

对“displayAllEmployees”的未定义引用

collect2:错误:ld返回了1个退出状态

CMakeFiles/struct.dir/build.make:94:目标“struct”的配方失败

生成[3]:***[struct]错误1

CMakeFiles/Makefile2:178:目标“CMakeFiles/struct.dir/all”的配方失败

生成[2]:***[CMakeFiles/struct.dir/all]错误2

CMakeFiles/Makefile2:190:目标“CMakeFiles/struct.dir/rule”的配方失败

生成[1]:***[CMakeFiles/struct.dir/rule]错误2

Makefile:157:目标“struct”的配方失败

生成:**[struct]错误2

我希望你们能帮我。在CMakeLists.txt中,我分别为person.c和struct.c设置了可执行文件。对于头文件,我初始化了函数,但每当我尝试运行struct.c文件时,它总是给出错误

结构c

    #include "person.h"

    int main(void)

    {
    int cnt;
    printf("How many employees? ");
    scanf("%d", &cnt);

    PERSON employees[cnt];

    for (int i = 0; i < cnt; i++)
    {
        PERSON employee;
        addEmployee(&employee);
        employees[i]= employee;
        printf("\n");
    }
    displayEmployee(&employees[0]);
    displayAllEmployees(employees,cnt);
    return 0;
}
#包括“person.h”
内部主(空)
{
int-cnt;
printf(“有多少员工?”);
scanf(“%d”和&cnt);
个人雇员[cnt];
对于(int i=0;i
c人

    #include "person.h"
    #include <stdio.h>

    void addEmployee(PERSON *employee)

    {
    DATE mydate;
    printf("Enter info for next employee.\n");
    printf("Name : ");
    scanf("%s", employee->name);
    printf("Age : ");
    scanf("%d", &employee->age);
    printf("Height : ");
    scanf("f",&employee->height);

    printf("Enter DOB: ");
    printf("Enter month: ");
    scanf("%d", &mydate.month);
    printf("Enter day: ");
    scanf("%d", &mydate.day);
    printf("Enter your year: ");
    scanf("%d", &mydate.year);
    employee->birthday = mydate;

    }

    void displayEmployee(PERSON *employee)

    {
    printf("Name: %s\n", employee->name);
    printf("Age: %d\n", employee->age);
    printf("Height: .1%f\n", employee->height);
    printf("Birthday: %d/%d/%d", employee->birthday.month,employee->birthday.day,employee->birthday.year);

}

    void displayAllEmployees(PERSON *employees[], int numberOfEmployees)

    {
    for(int i=0; i< numberOfEmployees;i++)
    {
        displayEmployee(employees[i]);
        employees++;
    }
    printf("\n");
}
#包括“person.h”
#包括
无效添加员工(个人*员工)
{
日期mydate;
printf(“输入下一个员工的信息。\n”);
printf(“名称:”);
scanf(“%s”,员工->姓名);
printf(“年龄:”);
scanf(“%d”,&employee->age);
printf(“高度:”);
scanf(“f”和员工->身高);
printf(“输入DOB:”);
printf(“输入月份:”);
scanf(“%d”、&mydate.month);
printf(“输入日期:”);
scanf(“%d”,&mydate.day);
printf(“输入您的年份:”);
scanf(“%d”和mydate.year);
员工->生日=我的日期;
}
无效显示员工(个人*员工)
{
printf(“姓名:%s\n”,员工->姓名);
printf(“年龄:%d\n”,员工->年龄);
printf(“高度:.1%f\n”,员工->高度);
printf(“生日:%d/%d/%d”,员工->生日.月,员工->生日.日,员工->生日.年);
}
void displayAllEmployees(个人*employees[],国际雇员人数)
{
对于(int i=0;i

#ifndef PERSON_H

#define PERSON_H

#include <stdio.h>

typedef char NAME[41];
typedef struct date

{
int month;
int day;
int year;
}DATE;
typedef struct person{
NAME name;
int age;
float height;
DATE birthday;
}PERSON;

void addEmployee(PERSON *employee);
void displayEmployee(PERSON *employee);
void displayAllEmployees(PERSON *employees[], int numberOfEmployees);


#endif //PERSON_H
\ifndef PERSON\u H
#定义人
#包括
typedef字符名[41];
类型定义结构日期
{
整月;
国际日;
国际年;
}日期;
typedef结构人{
姓名;
智力年龄;
浮动高度;
生日;
}人;
无效员工(人*员工);
无效显示员工(人*员工);
无效显示所有员工(个人*员工[],国际员工人数);
#endif//PERSON\u H
CMAKE:

cmake_最低要求(3.8版)

项目(c_tut)

套装(CMAKE_C_标准11)

设置(CMAKE_C_标志“-m64-g-O0-D_调试-墙”)

包含目录(在src之后)

添加可执行文件(person src/person.c)
添加可执行文件(struct src/struct.c)

person.h中的内容
?它不允许我这样做。它说代码太多了。你说错误是在“我运行struct.c文件”时出现的。它们实际上是编译器错误还是链接器错误?请在问题中发布完整的错误消息。不管怎样,我只是将其设置为
void displayAllEmployees(PERSON*employees,int numberOfEmployees)
。它是一个指针数组。