Re: [Rd] floating point control on windows

From: Chris Paulse <cpaulse_at_aecom.yu.edu>
Date: Mon 29 Aug 2005 - 16:23:29 GMT


Thanks for the guidance.

Using the following code fixed my problem:

#ifdef _WIN32

BOOL APIENTRY DllMain( HANDLE hModule,

                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
	if (ul_reason_for_call == DLL_PROCESS_ATTACH)
	{
		Rwin_fpset();
	}

    return TRUE;
}
#endif

-----Original Message-----
From: Prof Brian Ripley [mailto:ripley@stats.ox.ac.uk] Sent: Monday, August 29, 2005 10:53 AM
To: Chris Paulse
Cc: r-devel@r-project.org
Subject: Re: [Rd] floating point control on windows

We recommend calling Rwin_fpset() which is exported by R.dll and is known to do the trick. As it contains

     _controlfp(_PC_64, _MCW_PC);

it may be that the args you used are incorrect (and I am not on Windows to check the docs, but note that is the form used in the URL you cite).

On Mon, 29 Aug 2005, Chris Paulse wrote:

> Hi,
>
> I'm sure that this question has come up many times before.  When I load an
R
> extension dll I've built with the Microsoft compiler, I get the warning:
> Warning message:
>
> DLL attempted to change FPU control word from 8001f to 9001f
>
> So, what I did to try to fix the problem (to my knowledge, Microsoft will
> not support compile time switching of floating point control until version
> 8.0 of their compiler - see: http://blogs.msdn.com/ericflee) was to place
> the following statement inside R_init_mylib:

> _controlfp(_MCW_PC, _PC_64); // use extended precision for operations in x87

> FPU
>
> This didn't fix my problem.  I ended up sprinkling these liberally
> throughout my code, but that didn't help.  One thing I do like about the
> Microsoft compiler is the debugging facility.  But, I'll definitely switch
> to gcc if this is necessary to get rid of the problem.

-- 
Brian D. Ripley,                  ripley@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

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue Aug 30 02:40:16 2005

This archive was generated by hypermail 2.1.8 : Mon 24 Oct 2005 - 22:27:46 GMT