[Pkg-octave-devel] indexing expression performance

John W. Eaton jwe at octave.org
Sat Jan 17 19:51:36 UTC 2009


On 17-Jan-2009, Jaroslav Hajek wrote:

| For using them from Fortran, no, you can use the implicit interface
| generated for every call. For using them from C, a header file can be
| written. So far I didn't do it, because it appears that providing it
| is actually inconvenient for C++; in C++, it's more convenient to use
| references than pointers (as in Octave's sources).

You could write a header with some macro goo something like this:

  #if defined __cplusplus && defined (QRUPDATE_USE_REFERENCES)
  #define QRUPDATE_PTR_ARG(T) T&
  #else
  #define QRUPDATE_PTR_ARG(T) T*
  #endif

  #if defined (__cplusplus)
  extern "C" {
  #endif

  F77_FUNC_RET_T
  F77_FUNC (qrupdatefcn, QRUPDATEFCN) (const QRUPDATE_PTR_ARG (double),
                                       QRUPDATE_PTR_ARG (double), int)
  ...

  #if defined (__cplusplus)
  }
  #endif

But I'm not sure it is really worth it.

jwe



More information about the Pkg-octave-devel mailing list