[Top][All Lists]

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

C/C++ question for dynamically linked .oct functions

From: E. Joshua Rigler
Subject: C/C++ question for dynamically linked .oct functions
Date: Thu, 12 Jul 2001 12:31:32 -0600

Maybe this is a hopeless question, but I'll ask anyway...

I have a C library I'm trying to write an interface to in C++, so that I
can use it with Octave.  This C library does something I find odd, but
there's little I can do about it.  It has a single function that takes a
variable length argument list, and does different things based on what
arguments it is passed.  The odd part is that the arguments that
determine which actions are taken, and which inputs are required, are
supposed to be macros.

For example:

  CDFlib(OPEN_, CDF_, 'filename', &id)

...forces the CDFlib function to open a CDF file of name "filename", and
return the filehandle as a void pointer.  "OPEN_" is a macro that
expands to a long integer, and is defined in cdf.h.  Similarly, "CDF_"
is a macro that expands to a different long integer and is also defined
in cdf.h.

Now, I want to pass strings from Octave to CDFlib.oct, so that the
interface would be more like:

  id = CDFlib('OPEN_', 'CDF_', 'filename')

where id is now an index of an element of a static array of filehandle
pointers within CDFlib.oct (this is necessary since Octave can't handle
a pointer data type).

What I would like to do is simply convert the string into its macro.  I
realize that this is more-or-less impossible, since the macros are
expanded at compile time, but the alternative is to try to figure out
what each of the macros in cdf.h is supposed to expand to, and write a
huge conditional or switch statement to assign the proper long
integers.  This is not a desirable thing because 1) it would be a major
pain, and 2) I don't necessarily trust the macro expansions in cdf.h to
remain constant, but the macro names should.

Any ideas?


P.S. For those of you actually interested in what I'm working on, don't
worry about the non-intuitive nature of this interface.  It is only a
first step.  It will serve as a portal to the C CDF library for more
intuitive octave functions for manipulating CDF files.

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]