에 대한 몇 가지 오류 : 파일 iweardrv.h
을 포함 내가 추가 살고 있고 한C++ : 내 USB 주변 장치에서 데이터를 읽기 위해이 코드를 발견 CONST 문자 *와의 printf
#include "stdafx.h"
#define IWEARDRV_EXPLICIT
#include <windows.h>
#include <iweardrv.h>
int _tmain(int argc, _TCHAR* argv[])
{
// Load functions dynamically (in case they don't have a VR920)
HINSTANCE iweardll = LoadLibraryA("iweardrv.dll");
if (!iweardll) {
printf("VR920 drivers are not installed, you probably don't have a VR920.");
return 2;
}
IWROpenTracker = (PIWROPENTRACKER) GetProcAddress(iweardll, "IWROpenTracker");
IWRCloseTracker = (PIWRCLOSETRACKER) GetProcAddress(iweardll, "IWRCloseTracker");
IWRZeroSet = (PIWRZEROSET) GetProcAddress(iweardll, "IWRZeroSet");
IWRGetTracking = (PIWRGETTRACKING) GetProcAddress(iweardll, "IWRGetTracking");
IWRGetVersion = (PIWRGETVERSION) GetProcAddress(iweardll, "IWRGetVersion");
// Try to connect to the VR920 tracker
if (IWROpenTracker()) {
printf("VR920 is not connected.");
return 1;
}
// Read 20 samples
for (int i=1; i<=20; i++) {
LONG y, p, r;
double yaw, pitch, roll;
if (!IWRGetTracking(&y,&p,&r)) {
yaw = y*(180.0/32768.0);
pitch = p*(180.0/32768.0);
roll = r*(180.0/32768.0);
printf("Yaw=%lf degrees, Pitch=%lf degrees, Roll=%lf degrees", yaw, pitch, roll);
} else {
printf("Unable to read tracking.");
}
Sleep(500);
}
// Tidy up
IWRCloseTracker();
FreeLibrary(iweardll);
return 0;
}
디렉토리를 포함한다. 다음과 같은 오류 메시지가 표시됩니다.
IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR"
IntelliSense: identifier "printf" is undefined
오류를 방지하려면 어떻게합니까? 첫 번째 오류는 LoadLibrary
인수가 "iweardrv.dll"
(동적 라이브러리는 iweardrv.h
과 관련 있음)이며 두 번째 오류는 모두 printf
호출 줄을 나타냅니다.
편집 : const char*
이 걸리기 때문에 LoadLibraryA()
을 사용하여 첫 번째 오류를 수정했지만 두 번째 오류는 해결할 수 없습니다.
코드가 이중 간격을두고 들여 쓰여져 있지 않으므로 읽기가 매우 어려웠습니다. (웹 양식에 복사 한 방식의 인공물이었을 수도 있습니다.) 나는 당신을 위해 그것을 고쳤습니다. –