[Top][All Lists]

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

Simple oct function

From: Iago Mosqueira
Subject: Simple oct function
Date: Thu, 08 Aug 2002 16:16:34 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; gl-ES; rv:1.0.0) Gecko/20020615 Debian/1.0.0-3


I want to use some fortran subroutines from the GSLIB library in octave, and I am attempting for the first time to write a C++ wrapper. After reading the manual and a few other examples, I have the C++ and F77 functions attached at the end. There is some simple clash between int and octave_value_list, when I do

        mkoctfile addone.cpp -o addone.oct

I get

addone.cpp: In function `class octave_value_list Faddone(const octave_value_list &, int)':
addone.cpp:13: `retval' cannot be used as a function
addone.cpp:13: implicit declaration of function `int addone(...)'
addone.cpp:13: warning: cannot pass objects of type `octave_value' through `...' /usr/include/octave-2.1.36/octave/oct-obj.h:173: `octave_value_list::octave_value_list(int)' is private
addone.cpp:15: within this context

what is the problem here? I know almost nothing about C++ and F77, but if I could get this simple example running I would understand how to make the real subroutines work.

Many thanks



#include <octave/config.h>
#include <octave/oct.h>
#include <stdio.h>
#include <stdlib.h>

extern "C" int Addone_ (int *, int *);

DEFUN_DLD (addone, args, nargout,
  octave_value_list retval;

  retval(0) = addone(args(0));

  return retval;


subroutine addone(x,y)

integer x
integer y
y = 1 + x
end subroutine

Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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