|
Boost Users : |
From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2003-04-09 06:28:46
On Tuesday 08 April 2003 21:42, Paul Mensonides wrote:
> Toon Knapen wrote:
> > In the ublas forum we're having a discussion on the best way to
> > provide signatures in C for fortran libraries (like BLAS and LAPACK).
> > For linking C with fortran, you sometimes need to add an underscore
> > to the function in C, but on other platforms fortran will store
> > the function-name in capitals.
> >
> > Thus on different platforms, we should preprocess our source to take
> > the platforms' convention into account and we thus would need a macro
> > to convert an identifier automatically to uppercase. Is that possible
> > ?
>
> It is not _generally_ possible to pull apart the an arbitrary identifier.
> However, if the identifier is _already_ pulled apart, it is possible. E.g.
> dealing with "identifier" is not possible in a general fashion; dealing with "i
> d e n t i f i e r" is possible, and the identifier itself could be abstracted to
> something like:
>
> FORTRAN_ID( identifier )
>
> For example, if you have these identifiers:
>
> abc, xyz, pqr
>
> #define FORTRAN_ID_abc a b c
> #define FORTRAN_ID_xyz x y z
> #define FORTRAN_ID_pqr p q r
>
> You can get:
>
> FORTRAN_ID( abc ) >> abc, _abc, or ABC
> FORTRAN_ID( xyz ) >> xyz, _xyz, or XYZ
> FORTRAN_ID( pqr ) >> pqr, _pqr, or PQR
>
> If that sounds okay, I can implement it for you.
OK, so there are 3 different possibilities here :
1) all manual
For the bindings we #ifdef on the platform to determine
how to convert identifiers (to match their fortran counterpart) and
then define an identifier for every function (with the additonal underscore ...)
e.g.
#ifdef __sgi
#define DAXPY daxpy_
#endif
2) Wave (as suggested by Hartmut Kaiser)
Use wave to create a header from an input-file. This puts
a strong dependency on Wave and although the tool is impressive,
this will make it difficult for people to add a new binding IMHO.
3) Suggestion above of Paul Mensonidis
This option will give us minimal work, we could just write IIUC
FORTRAN_ID( d a x p y ).
(Paul: could we leave out the seperation of the characters if we always
provide seperated characters directly as in the line above ?)
However, this solution might limit portability.
Although I'm used to option 1, I would like to go for option 3
(although maybe looking at the portability of the pp lib would not hurt)
Opinions ?
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net