我正在尝试使用Irrlicht创建一个程序,该程序从Lua编写的配置文件加载某些东西,其中一个是窗口标题.但是,该lua_tostring函数返回一段const char*时间Irrlicht设备的方法setWindowCaption需要a const wchar_t*.如何转换返回的字符串lua_tostring?
我正在尝试学习如何将 lua 嵌入到 C 程序中,但我不擅长阅读技术文档,而且我还没有找到任何当前的教程。这是我的程序:
#include <iostream>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
void report_errors(lua_State*, int);
int main(int argc, char** argv) {
for (int n = 1; n < argc; ++n) {
const char* file = argv[n];
lua_State *L = luaL_newstate();
luaL_openlibs(L);
std::cerr << "-- Loading File: " << file << std::endl;
int s = luaL_loadfile(L, file);
if (s == 0) {
s = lua_pcall(L, 0, LUA_MULTRET, 0);
}
report_errors(L, s);
lua_close(L);
std::cerr << std::endl;
}
return 0;
}
void …Run Code Online (Sandbox Code Playgroud) 我正在关注SDL教程并遇到了一个问题.当我编译我的程序时,它会给出错误
/home/cevent.h 9 error: expected unqualified-id before '-' token
/home/cevent.cpp 5 error: expected unqualified-id before '-' token
Run Code Online (Sandbox Code Playgroud)
我的代码如下:
头文件
//cevent.h
#ifndef CEVENT_H
#define CEVENT_H
#include <SDL/SDL.h>
class CEvent {
public:
CEvent();
virtual -CEvent();
void onEvent(SDL_Event *event);
virtual void onExit();
//and various other virtual method declarations
};
#endif // CEVENT_H
Run Code Online (Sandbox Code Playgroud)
和源文件
//cevent.cpp
#include "cevent.h"
CEvent::CEvent() {}
CEvent::-CEvent() {}
void CEvent::onEvent(SDL_Event *event) {
switch(event->type) {
//some code for handling events
}
}
//some temporarily empty method definitions
Run Code Online (Sandbox Code Playgroud)
我已经挖掘了多个类似问题的在线解决方案,但我找不到满足我的问题的解决方案,也没有找到基于我读过的解决方案.