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

Jeff D. Hamann jeff_hamann at hamanndonald.com
Sun Feb 16 05:33:03 CET 2003


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




More information about the R-help mailing list