我已经让 Derelict3 在 DMD 2.xx 下工作,但现在我无法将我的 SDL 代码从 C++ 移植到 D,以下代码给了我这个错误:
C:\Documents and Settings\Kevin Kowalczyk\My Documents\Code\D\Snippets\Dereli
DL>dmd main.d
main.d(14): Error: undefined identifier SDL_SetVideoMode
main.d(14): Error: undefined identifier SDL_HWSURFACE
main.d(14): Error: undefined identifier SDL_DOUBLEBUF
main.d(15): Error: undefined identifier SDL_WM_SetCaption
main.d(21): Error: cannot implicitly convert expression (SDL_Quit) of type ex
n (C) void function() nothrow to uint
main.d(20): Error: non-final switch statement without a default is deprecated
这是代码:
import std.stdio;
import derelict.sdl2.sdl;
pragma(lib, "DerelictSDL2.lib");
pragma(lib, "DerelictUtil.lib");
SDL_Surface Surf_Display;
bool running = true;
void main() {
DerelictSDL2.load();
SDL_Init(SDL_INIT_EVERYTHING);
SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_WM_SetCaption("Derelict3SDL test", null);
SDL_Event event;
while(running) {
while(SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_Quit:
running = false;
}
}
}
}