[Rd] How to set R_CStackLimit

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Jun 28 22:32:12 CEST 2007

First, Rinterface.h is not installed on Windows, so you must be using a 
header from within the R sources.  You do so at your own peril!

R_CStackLimit is only described in a Unix-specific section of 'Writing R 
Extensions'.  The description there and Rinterface.h is designed for Unix 
compilers, not for Windows compilers.  Since R_CStackLimit is a variable 
exported from a DLL, many Windows compilers will need it declared as a 
dllimport.  You have not told us your compiler (but 'Rdll.lib' is not part 
of R and not needed for the recommended MinGW).  If (as I guess) it is 
Visual Studio, you need to heed the comments in README.packages about 

On Thu, 28 Jun 2007, Xiaoning wrote:

> Hi,
> I have tried to disable stack checking by set R_CStackLimit to -1. However,
> it always crashes my win32 multiple threads program. I am using R-2.5.0. My
> code looks like:
> #include <Rversion.h>
> #if (R_VERSION >= R_Version(2,3,0))
> #define R_INTERFACE_PTRS 1
> #define CSTACK_DEFNS 1
> #include <Rinterface.h>
> #endif
> and then, add below line to my main function:
>    R_CStackLimit = (uintptr_t)-1;  //crashes when step to this line.
> As for input library in link option, I only link to Rdll.lib. Am I missing
> something?
> Thanks very much!
> xzhang

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-devel mailing list