C++ is a case-senstiive language. readIt
is not the same as ReadIt
.
ld: symbol(s) not found for architecture x86_64 error on array of structs [closed]
Frage
running into this odd error when passing a type def of array of structs to a function. My code is below:
#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++ gives the following error:
Undefined symbols for architecture x86_64:
"ReadIt(std::__1::basic_ifstream >&, Grades*, int&)", referenced from: _main in Grades-10db96.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Lösung
Andere Tipps
in the declaration you're using gradeRec
whereas in the definition you're using gradeRec&
. Those are two different symbols.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow