小编Gia*_*e47的帖子

将const char*转换为const wchar_t*

我正在尝试使用Irrlicht创建一个程序,该程序从Lua编写的配置文件加载某些东西,其中一个是窗口标题.但是,该lua_tostring函数返回一段const char*时间Irrlicht设备的方法setWindowCaption需要a const wchar_t*.如何转换返回的字符串lua_tostring

c++ irrlicht type-conversion

7
推荐指数
1
解决办法
1万
查看次数

Lua 5.3 未定义引用

我正在尝试学习如何将 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)

c++ lua

4
推荐指数
1
解决办法
3009
查看次数

C++错误:在' - '标记之前预期的nonqualified-id

我正在关注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)

我已经挖掘了多个类似问题的在线解决方案,但我找不到满足我的问题的解决方案,也没有找到基于我读过的解决方案.

c++

-1
推荐指数
1
解决办法
1700
查看次数

标签 统计

c++ ×3

irrlicht ×1

lua ×1

type-conversion ×1