ld:在结构数组上找不到体系结构x86_64错误的符号

ld: symbol(s) not found for architecture x86_64 error on array of structs

本文关键字:x86 错误 符号 体系结构 找不到 结构 数组 ld      更新时间:2023-10-16

在将结构数组的类型def传递给函数时遇到这个奇怪的错误。我的代码如下:

#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;

const int MAXRECORDS = 50;
struct Grades                             // declares a structure
{
    char name[NAMESIZE + 1];
};
typedef Grades gradeType[MAXRECORDS];  

void ReadIt( ifstream &i, gradeType gradeRec, int &h);
int main()
{    
     ifstream indata;
     int numRecord;                // number of records read in
     gradeType studentRecord; 
     /* Some stuff */
     ReadIt(indata, studentRecord, numRecord);               
    /* Other Stuff*/
    return 0;
}

void readIt(ifstream &inData, gradeType gradeRec, int &total)
{
    // never make it here, does not compile
}

g++给出以下错误:

体系结构x86_64的未定义符号:
"ReadIt(std::__1::basic_ifstream>&,成绩*,int&)",引用自:_等级-10db96中的main。o ld:找不到体系结构x86_64的符号clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)

C++是一种区分大小写的语言。CCD_ 1与CCD_。

声明中使用的是gradeRec,而在定义中使用的却是gradeRec&。这是两个不同的符号。

相关文章: