help-octave
[Top][All Lists]
Advanced

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

Re: mkoctfile and C


From: John W. Eaton
Subject: Re: mkoctfile and C
Date: Mon, 21 Feb 2011 12:37:02 -0500

On 21-Feb-2011, Laurent Hoeltgen wrote:

| On Mon, 2011-02-21 at 08:39 -0600, Jordi Gutiérrez Hermoso wrote:
| > On 21 February 2011 03:46, Laurent Hoeltgen <address@hidden> wrote:
| > > I was wondering if there is some magic behind compiling C code with
| > > mkoctfile. On the octave webpages, there's this short example written in
| > > C++ which compiles fine for me. However, I can't get anything to run
| > > once it's in plain C.
| > 
| > The Octave headers are in C++, so you can't #include them from files
| > that are intended to be C, which is a different language. The errors
| > you are seeing are what happens when a C compiler sees C++ code in
| > oct.h.
| > 
| > You could write C wrappers for the Octave headers, if you want to do the 
work.
| > 
| > - Jordi G. H.
| 
| Thanks for the info. But in that case, I think the text at
| 
http://www.gnu.org/software/octave/doc/interpreter/Getting-Started-with-Oct_002dFiles.html
 is a bit misleading, because there it says in the first sentence:
| 
| "The mkoctfile function compiles source code written in C, C++, or
| Fortran."
| 
| and a few paragraphs later you get told that you need the octave header
| files.

Octave expects the interface routine (the function defined by the
DEFUN_DLD macro) to be written in C++.  So that part must be written
in C++, but from there you can call C, Fortran, whatever.  There are
plenty of examples of doing just that in the Octave sources.

Wrapping the Octave headers in C doesn't make much sense to me as
there are many things in there that can't be expressed directly in C.

jwe


reply via email to

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