#include <windows.h>
#include <dinput.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HRESULT hr;
LPDIRECTINPUT8 g_lpDI;
hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&g_lpDI, NULL);
return 0;
}
DirectInput and C
hi,
i'm trying to compile a few simple lines of code with the newest dxsdk.
unfortunately i'm getting this errormessage:
C:\Program Files\Microsoft DirectX SDK (April 2007)\Include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
dinput.c(12) : error C2440 'function' : cannot convert from 'const GUID' to 'const IID *const'
dinput.c(12) : warning C4024: 'DirectInput8Create' : different types for formal and actual parameter 3
when i rename dinput.c to dinput.cpp the code compiles without problems. what do i have to do, to use the inputfunctions with c? i tried to google but all tutorials i have found focus on directinput with c++.
LessBread is correct on the first error. The second error is because C doesn't support references, so the code compiles differently, expecting a GUID pointer instead of a reference. When you rename the file to .cpp, it compiles as C++ code, which can use references.
So, if you want to use a .c file, you need to change the line to:
hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8, (void**)&g_lpDI, NULL);
(I think, untested).
So, if you want to use a .c file, you need to change the line to:
hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, &IID_IDirectInput8, (void**)&g_lpDI, NULL);
(I think, untested).
DirectX is totally object oriented though, implementing the COM model, so you do NOT want to try and use it in C.
Quote:Original post by tok_juniorI agree. C++ would be much more suitable. However, it is still possible to use C if you have to (DirectX has C methods for accessing the COM objects).
DirectX is totally object oriented though, implementing the COM model, so you do NOT want to try and use it in C.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement