这是我的函数声明。使用 Visual Studio 2010 C++ 时出现 Unresolved external 错误。
bool CheckCrcByte(const CHAR_t* pbData, UINT32_t lLength, UINT32_t lMsgCrc)
{
bool FlagPass;
UINT32_t lCalcCrc;
UINT32_t lInitCrc = 0;
lCalcCrc = ~lInitCrc;
CHAR_t* bCurrent = (CHAR_t*) pbData;
while (lLength-- > 0)
{
lCalcCrc = (lCalcCrc >> 8) ^ crc_TABEL[(lCalcCrc & 0xFF) ^ *bCurrent++];
}
lCalcCrc = ~lCalcCrc;
if (lMsgCrc == lCalcCrc)
{
FlagPass = true;
}
else
{
FlagPass = false;
}
return FlagPass;
}
最佳答案
这意味着您已经声明了该函数:
bool CheckCrcByte(char const *,unsigned int,unsigned int);
但是你还没有定义它。要定义它,请在
.cpp
中执行以下操作文件:bool CheckCrcByte(char const * c,unsigned int i1,unsigned int i2)
{
//Your function code goes here.
}
始终确保声明的函数原型(prototype)与其标识符和参数类型的定义相匹配。
在以下代码中:
bool CheckCrcByte(const CHAR_t* pbData, UINT32_t lLength, UINT32_t lMsgCrc)
{
//YOUR TYPES ARE NOT THE SAME THEREFORE IT IS A DIFFERENT FUNCTION DEFINITION
}
根据您告诉我您在评论中定义的内容,您已经定义了第二个函数,但您还需要定义第一个函数。它们是两种不同的功能。
关于c++ - 修复链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18014234/