SDL 找不到我的主要功能

SDL can't find my main function

本文关键字:功能 我的 找不到 SDL      更新时间:2023-10-16

我用SDL框架设置了我的应用程序,它可以正常工作,没有任何错误。但当我尝试启动程序时,它会立即终止,甚至在进入我的简单主方法之前。这里的代码:

#include "CApp.h"
#include <iostream>
int main(int argc, char* argv[]) {
    std::cout << "Hello";  
    return 0;
}

我知道SDL在SDLMain.m中实现了自己的主要功能,并手动启动了我的主要功能。我想我在STMain.m中找到了执行我的主要功能的代码(第222ff行):

/* Create SDLMain and make it the app delegate */
sdlMain = [[SDLMain alloc] init];
[NSApp setDelegate:sdlMain];
/* Start the main event loop */
[NSApp run];

当我在[NSApp run]上设置断点并向前迈出一步时,程序终止。

SDL #definemainSDL_main,以便透明地使用其自己的main实现。由于您还没有包含任何SDL标头,因此您的作用域中没有该宏。只需将main重命名为SDL_main或包含一个SDL头(如SDL.h)即可。