我对此事感到难过:
recorders/r5000device.cpp: In function ‘unsigned int r5000_device_tspacket_handler(unsigned char*, int, void*)’:
recorders/r5000device.cpp:34:14: warning: no previous declaration for ‘unsigned int r5000_device_tspacket_handler(unsigned char*, int, void*)’ [-Wmissing-declarations]
unsigned int r5000_device_tspacket_handler(unsigned char *tspacket, int len, void *callback_data)
^
recorders/r5000device.cpp: In function ‘void r5000_msg(char*)’:
recorders/r5000device.cpp:44:6: warning: no previous declaration for ‘void r5000_msg(char*)’ [-Wmissing-declarations]
void r5000_msg(char * msg)
^
答案 0 :(得分:8)
您已设置编译标志 -Wmissing-declarations 。编译器希望查看所有函数的声明(原型 - 通常在标题中)。只需添加缺少的标题或在文件顶部声明原型。
答案 1 :(得分:0)
C ++中的自由函数需要在头文件中声明,也需要在.cpp文件中定义。 How do you define a global function in C++?