程序有:raw_mouse.h,raw_mouse.c RawInputRegistry.h RawInputRegistry.cpp和main.cpp
在raw_mouse.h中,
我定义了:
typedef WINUSERAPI INT (WINAPI *pGetRawInputDeviceList)(OUT PRAWINPUTDEVICELIST pRawInputDeviceList, IN OUT PINT puiNumDevices, IN UINT cbSize);
void testme();
在raw_mouse.c中我有:
_RRID = (pRegisterRawInputDevices)GetProcAddress(user32,"RegisterRawInputDevices");
void testme()
{
int a =10;
}
我在raw_mouse.c中包含了raw_mouse.h,并在RawInputRegistry.h中包含了raw_mouse.h,最后在main.cpp中包含了RawInputRegistry.h
但是,我收到了这些错误:
RawInputRegistry.obj : error LNK2005: "int (__stdcall* _GRID)(struct HRAWINPUT__ *,unsigned int,void *,int *,unsigned int)" (?_GRID@@3P6GHPAUHRAWINPUT__@@IPAXPAHI@ZA) already defined in main.obj
RawInputRegistry.obj : error LNK2019: unresolved external symbol "void __cdecl testme(void)" (?testme@@YAXXZ) referenced in function "protected: __thiscall RawInputEventRegistry::RawInputEventRegistry(void)" (??0RawInputEventRegistry@@IAE@XZ)
不确定我是否应该使用extern“C”来包含raw_mouse.c中的所有代码?
答案 0 :(得分:1)