我在 C 中不断收到错误LNK2019或未解决的外部符号错误,但看不出原因

I keep getting error LNK2019 or unresolved external symbol error in C and can not see why

提问人:FishLord 提问时间:11/23/2021 更新时间:11/23/2021 访问量:84

问:

我收到错误未解决的外部符号_applicationStartup函数 main 中引用。我正确声明和定义了函数,但它一直给出错误。这些是代码的主要部分,所有内容都存储并保存在同一个文件中。

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

#define ACCOUNT_SIZE 50
#define TICKET_SIZE 50

void populateAccounts(struct Account accounts[], int arrSize);
void populateTickets(struct Ticket tickets[], int arrSize);

int main(void)
{
 
    struct Account accounts[ACCOUNT_SIZE] = { {0} };
   
    struct Ticket tickets[TICKET_SIZE] = { {0} };

    struct AccountTicketingData data = { accounts, ACCOUNT_SIZE, tickets, TICKET_SIZE };

    populateAccounts(data.accounts, data.ACCOUNT_MAX_SIZE);

    populateTickets(data.tickets, data.TICKET_MAX_SIZE);

  
    applicationStartup(&data);

    return 0;
}

在 accountTicketingUI.h 中,我首先声明应用程序启动。

#include <stdio.h>
#include "account.h"
#include "ticket.h"





void applicationStartup(struct AccountTicketingData*);//starting function to call everything


void pauseExecution(void);//pause function
int displayAccountDetailHeader();//displays the header 
int displayAccountDeatailRecord(struct Account *);//function to display records

int menuLogin(const struct Account accounts[], int max);//login function
int menuAgent(struct AccountTicketingData*, const int ptr);//menu for the user

int displayAllAccountDetailRecords(const struct Account accounts[], int max);//displas everything an encrypts it

int findAccountIndexByAcctNum(int num, const struct Account accounts[], int max, int prompt);

struct AccountTicketingData
{
    struct Account* accounts;
    const int ACCOUNT_MAX_SIZE;
    struct Ticket* tickets;
    const int TICKET_MAX_SIZE;
};

这是应用程序启动的实际代码

void applicationStartup(struct AccountTicketingData *accounts[]) 
{
    int index;//loops and index holders

    while (1)
    {
        index = menuLogin(accounts, ACCOUNT_MAX_SIZE); 

        if (index != -1)
        {
            menuAgent(accounts, ACCOUNT_MAX_SIZE, index); 
        }
        else {
            break;
        }

    }
    printf("==============================================\n");
    printf("Account Ticketing System - Terminated\n");
    printf("==============================================\n\n");
}
C 函数 LNK2019 未解析-外部

评论

0赞 kiner_shah 11/23/2021
applicationStartup 在哪里定义?
1赞 FishLord 11/23/2021
@kiner_shah,它是在名为 accountTicketingUI.c 的文件中定义的
1赞 H.S. 11/23/2021
type 函数参数在其原型(在头文件中)和定义中是不同的。从定义中的参数中删除 - 。applicationStartup()[]applicationStartup(struct AccountTicketingData *accounts[])
2赞 Eric Postpischil 11/23/2021
该帖子说“所有内容都存储并保存在同一个文件中”,但显示声明在“accountTicketingUI.h”中,这表明并非所有内容都在一个文件中。澄清陈述。源代码所在的文件的名称是什么?源代码所在的文件的名称是什么?你怎么知道包含的文件是否正在被编译并链接到你的程序中?mainapplicationStartupapplicationStartup

答: 暂无答案