PDCurses TUI C ++ Win32控制台应用程序 - 访问冲突读取位置 [英] PDCurses TUI C++ Win32 console app - Access violation reading location

查看:322
本文介绍了PDCurses TUI C ++ Win32控制台应用程序 - 访问冲突读取位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经下载 pdcurses 源,并能成功地包括curses.h里在我的项目,挂钩pre-编译的库和所有的好。

I have downloaded pdcurses source and was able to successfully include curses.h in my project, linked the pre-compiled library and all good.

尝试出库的几个小时后,我看到了tuidemo.c在演示文件夹,它编译成可执行和辉煌!正是我需要为我的项目。

After few hours of trying out the library, I saw the tuidemo.c in the demos folder, compiled it into an executable and brilliant! exactly what I needed for my project.

现在的问题是,它是一个C code和我工作的一个C在VS C ++ 2008。

Now the problem is that it's a C code, and I am working on a C++ project in VS c++ 2008.

我所需要的文件tui.c和tui.h
我怎么能包括我的C ++ code的C文件?我看到 rel=\"nofollow\">几个建议

The files I need are tui.c and tui.h How can I include that C file in my C++ code? I saw few suggestions here

但编译器是不是太满意,警告和错误100的。

but the compiler was not too happy with 100's of warnings and errors.

如何可以去,包括/使用TUI pdcurses包括!?

How can I go on including/using that TUI pdcurses includes!?

感谢

编辑:

我添加的externC语句,所以我的测试看起来现在这​​个样子,但我得到一些其他类型的错误

I added extern "C" statement, so my test looks like this now, but I'm getting some other type of error

#include <stdio.h>
#include <stdlib.h>
using namespace std;

extern "C" {
   #include <tui.h>
}

void sub0()
{
    //do nothing
}

void sub1()
{
    //do nothing
}


int main (int argc, char * const argv[]) {

    menu MainMenu[] =
    {
        { "Asub", sub0, "Go inside first submenu" },
        { "Bsub", sub1, "Go inside second submenu" },
        { "", (FUNC)0, "" }   /* always add this as the last item! */
    };
    startmenu(MainMenu, "TUI - 'textual user interface' demonstration program");

    return 0;
}

虽然它成功编译,它是扔在运行时错误,这表明一个坏的指针:

Although it is compiling successfully, it is throwing an Error at runtime, which suggests a bad pointer:

0xC0000005: Access violation reading location 0x021c52f9

在行

startmenu(MainMenu, "TUI - 'textual user interface' demonstration program");

不知道从哪里何去何从。
再次感谢。

Not sure where to go from here. thanks again.

推荐答案

终于得到了它的工作。解决的办法是在下面的步骤进行:

Finally got it working. The solution was in the steps below:

首先,我改名为tui.c tui.cpp

First I renamed tui.c to tui.cpp

有关的头tui.h​​,我跟着的确切的描述包裹code的同一步骤中的这里

For the header tui.h, I followed the exact same step of wrapping the code as described here.

然后在我的项目,我只是包括头部没有任何的externC块

then in my project i just included the header without any extern "C" block

#include "tui.h"

编译和它的工作!

Compiled and it worked!

这篇关于PDCurses TUI C ++ Win32控制台应用程序 - 访问冲突读取位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆