[R] __stdcall funcitons called using .C() on win32 chokes

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Sun Feb 16 09:18:03 CET 2003


Just add a glue routine to provide a _cdecl interface.

Note, it is a .C interface and not a .Pascal interface.  You could write a 
.Pascal, of course.

On Sat, 15 Feb 2003, Jeff D. Hamann wrote:

> I've developed a dll (win32) of a bunch of functions prototypes as:
> 
> /* for building on *nix */
> #ifndef WIN32
> #define __stdcall /*nothing*/
> #endif
> 
> 
> void __stdcall dbh_2_height(
>   const unsigned long    *func_idx,
>   const unsigned long    *metric,
>   const unsigned long    *species,
>   const double             *dbh,
>   double                        *pred_height );
> 
> and have created a R interface function as,
> 
> ## wrapper function for dbh_2_height /
> dbh2height <- function( func, metric, sp, dbh )
> {
>     d <- double(length(func))
> 
>     .C("dbh_2_height",
>       as.integer(func),
>       as.integer(metric),
>       as.integer(sp),
>       as.double(dbh),
>       d )[[5]]
> }
> 
> I would like to keep the __stdcall in the source code and still use the
> .C() in R to call the function as the library is already used for many
> other projects. When I attempt to call the function (win32) I get an
> application error. I've commented out the __stdcall and the library works
> fine. Does anyone see a good solution around this? I would like to make
> use of the library and the tcltk library to use R as a simulation
> environment.
> 
> Jeff.
> 
> 
> Jeff D. Hamann
> PO Box 1421
> Corvallis, Oregon USA 97339-1421
> 541-753-7333
> www.hamanndonald.com
> jeff_hamann at hamanndonald.com
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list