[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Octave/C++
From: |
Mike Morley |
Subject: |
Re: Octave/C++ |
Date: |
22 Jul 2005 16:43:15 +0100 |
It occured to me that I needed to allocate some memory to my robot,
otherwise it would cease to be when the C++ subroutine exited. I now have
the code:
#include<iostream>
#include<octave/oct.h>
#include<octave/dynamic-ld.h>
#include<string>
using namespace std;
extern "C" {
#include "robot_instr.h"
#include "robot_link.h"
}
class Bot: public octave_base_value
{
public:
//constructor
Bot(void): octave_base_value()
{
robot_link robot;
}
//destructor
~Bot(void)
{
delete this;
}
DECLARE_OCTAVE_ALLOCATOR
};
DEFINE_OCTAVE_ALLOCATOR (Bot);
DEFUN_DLD(BotMake,,nargouts,
"BotMake creates a new robot to link in to")
{
Bot *b = new Bot();
return octave_value(b);
}
DEFUN_DLD(BotKill,args,,
"BotKill destroys the Bot")
{
if (args.length() == 1) {
delete ((Bot*)&args(0));
}
}
However, this now produces the error:
Bot.cpp: In function (character rendered as a-circumflex):
Bot.cpp:49: warning: taking address of temporary
And the error: "Segmentation Fault" when I run BotMake in octave
I don't really understand what this means. Any help would be appreciated.
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- Re: Octave/C++, (continued)
- Re: Octave/C++, Søren Hauberg, 2005/07/22
- Re: Octave/C++, Geraint Paul Bevan, 2005/07/22
- Re: Octave/C++, Mike Morley, 2005/07/22
- Re: Octave/C++, Søren Hauberg, 2005/07/22
- Re: Octave/C++, Geraint Paul Bevan, 2005/07/22
- Re: Octave/C++, Mike Morley, 2005/07/22
- Re: Octave/C++,
Mike Morley <=
- Re: Octave/C++, John W. Eaton, 2005/07/22
- Re: Octave/C++, Mike Morley, 2005/07/25
- Re: Octave/C++, Stefan van der Walt, 2005/07/25
- Re: Octave/C++, Mike Morley, 2005/07/26
Re: Octave/C++, Raphael Schneider, 2005/07/22