【问题标题】:SDL - Can't close program even using the task managerSDL - 即使使用任务管理器也无法关闭程序
【发布时间】:2021-10-29 10:02:14
【问题描述】:

程序“正确”编译(出现.exe 文件),但即使我关闭笔记本电脑也无法关闭(任务管理器也不工作)。关闭它的唯一方法是关闭它。怎么了?另外,当我编译项目时,Code::Blocks 会显示这个:

Running project post-build steps
XCOPY (invalid)\bin\*.dll bin\Debug\ /D /Y
ЌҐ ­ ©¤Ґ­ д ©«: *.dll
‘Є®ЇЁа®ў ­® д ©«®ў: 0.
Process terminated with status 4

【问题讨论】:

  • 也许你的杀毒软件有问题。如果不是这样,您将不得不以某种方式产生更多细节。您基本上是在要求我们在几乎没有任何信息的情况下调试您的操作系统的问题。

标签: c++ windows-7 sdl codeblocks


【解决方案1】:

鉴于没有任何信息,我猜您的程序中有主循环,但您没有在主循环中使用 SDL_Quit 枚举器来检查您是否尝试退出程序(alt + f4 和 ' X' 等)基本上一个简单的 SDL 应用程序应该如下所示:

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <SDL.h>

int main (int argc, char* args[] )
{

 SDL_Event event;
 bool exit = false;
 
 SDL_Window *window = SDL_CreateWindow ("title",
                                        SDL_WINDOWPOS_CENTERED,
                                        SDL_WINDOWPOS_CENTERED,
                                        1000,
                                        500,
                                        SDL_WINDOW_SHOWN)

 while(exit == false)
 {
  while(SDL_PollEvent(&event) >= 0)
  {
     if(event.type == SDL_Quit)
     {
      exit = true; // when this becomes true, the program terminates 
     }
     //other events goes here
   }
 }
  SDL_DestroyWindow(window);
  SDL_Quit();
}

看看这段代码是否在你的电脑上运行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多