Call C (or C++) with pointer to static function

Simen kjaeraas simen.kjaras at gmail.com
Mon Oct 11 05:39:05 PDT 2010


Michael Stover <michael.r.stover at gmail.com> wrote:

> I am under the impression that passing a pointer to a static function  
> (ie,
> passing a pointer to a memory address that contains the starting point  
> of a
> function) is not the same as defining a method that can be called by name
> from C code.  I am not a C expert though.

Well, yes and no. Given

extern( C ) returnType myFunc( /* args */ ) {}

You still have no function pointer to it. That is however easy to procure:

someCfunctionThatExpectsAfnPointer( &myFunc );

It could be that there is some hidden detail of C static functions that I
don't know, but i believe this works.


> Can one call fortran libraries from D?  Ie, say one wanted to use LAPACK
> from D?

http://dsource.org/projects/scid uses LAPACK, so I guess it is possible.

> Also, know of any mathematical libraries written in D (like  
> implementations
> of runge-kutta, linear algebra routines and data structures,  
> optimization or
> curve-fitting algorithms)?

At least some of this has been mentioned time and time again on the
newsgroup, you should be able to find it by searching.

 From dsource.org/projects:

http://dsource.org/projects/scid
http://dsource.org/projects/dstats

-- 
Simen


More information about the Digitalmars-d mailing list