help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: basic DLD help?


From: Søren Hauberg
Subject: Re: basic DLD help?
Date: Tue, 12 Jul 2005 15:06:32 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050404)

Hi,
You need to return something. If you need to return the number 7, do this:

return octave_value(7);

If you need to return several values do:

octave_value_list ret;
ret.append(value1);
ret.append(value2);
// on so on...
return ret;

If you don't want to return anything at all, do:

return octave_value();

The last one is easy to forget.It would be nice if the compiler was able to catch this, but apperently it can't.

/Søren

Shai Ayal wrote:
Hi all,

I am probably missing something basic here, but why does this not work?

[bash] > cat > test.cc
#include "oct.h"

DEFUN_DLD (test, args, ,"")
{

  double* y = args(0).vector_value().fortran_vec();

  octave_stdout << ">> " << y[0] << "," << y[1] << "\n";


}
EOF

[bash] > mkoctfile -v test.cc
g++ -c -fPIC -I/usr/local/include/octave-2.1.71 -I/usr/local/include/octave-2.1.71/octave -I/usr/local/include -mieee-fp -g -O2 test.cc -o test.o g++ -shared -Wl,-Bsymbolic -o test.oct test.o -L/usr/local/lib/octave-2.1.71 -loctinterp -loctave -lcruft -lcblas -lf77blas -latlas -lfftw3 -lreadline -lncurses -ldl -lm -L/usr/lib/gcc-lib/i386-redhat-linux/3.3.2 -L/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/../../.. -lfrtbegin -lg2c -lm -lgcc_s


[bash] > octave
GNU Octave, version 2.1.71 (i686-pc-linux-gnu).
Copyright (C) 2005 John W. Eaton.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTIBILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type `warranty'.

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html

Report bugs to <address@hidden> (but first, please read
http://www.octave.org/bugs.html to learn how to write a helpful report).

octave:1> a=[1,2,3];
octave:2> test(a)
panic: Segmentation fault -- stopping myself...
 >> 1,2
attempting to save variables to `octave-core'...
save to `octave-core' complete
Segmentation fault




-------------------------------------------------------------
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
-------------------------------------------------------------




-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]