I have used crc in my program.ViewDidLoad method code in ViewController.mm is below:
char *testChars = "test chars";
crc32(0, (unsigned char*)testChars, strlen(testChars));
crc32 function code is below:
uint32_t crc32 (uint32_t crc, unsigned char *buf, size_t len)
{
unsigned char *end;
crc = ~crc;
for (end = buf + len; buf < end; ++buf)
crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
return ~crc;
}
compile error is :
Undefined symbols for architecture x86_64,"crc32(unsigned int, unsigned char*, unsigned long)", referenced from:-[ViewController viewDidLoad:] in ViewController.o.
After I changed ViewController.mm to ViewController.m, compiled successfully. Why?