From ripley at stats.ox.ac.uk  Thu Nov 23 12:13:44 2006
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu, 23 Nov 2006 11:13:44 +0000 (GMT)
Subject: [Rd] Ralloc clash
In-Reply-To: <op.tjgtmjpmffxks9@norisk>
References: <op.tjfcqia2ffxks9@norisk>
	<Pine.LNX.4.64.0611222114200.1510@gannet.stats.ox.ac.uk>
	<op.tjgtmjpmffxks9@norisk>
Message-ID: <Pine.LNX.4.64.0611231106510.16220@gannet.stats.ox.ac.uk>

Realloc is defined in R_ext/RS.h, and only if STRICT_R_HEADERS is not 
defined.  This *is* documented in 'Writing R Extensions'.

On Thu, 23 Nov 2006, Tom McCallum wrote:

> Thank you for your reply.  My mistake - I meant Realloc (missed the 'e').
> This morning I reinstalled MinGW with all the patches suggested by the
> Install R on Windows Help page, including w32api-3.7, just to make sure
> all was as it should be.  I have put
>
> #define WIN32_LEAN_AND_MEAN
>
> at the top of my cpp file (which I did not know about so that was
> interesting) but it is still saying there is a conflict between Realloc in
> objidl.h and windows.h.  Interesting I had a C file which I _did_ manage
> to compile with the R.h and windows.h file in without this error coming
> up.  Could there be something going on with g++ that gcc is ignoring?  I
> am no sure it iss a clash now as I cannot find Realloc in the R includes
> but below is some output I have gathered which may be of assistance.
>
> In objidl.h (line 532):
>         STDMETHOD_(void*,Realloc)(THIS_ void*,ULONG) PURE;
>
> In R.h it has the solitary line:
> 	/* for PROBLEM ... Calloc, Realloc, Free, Memcpy, F77_xxxx */
> 	Can only find a R_alloc but no Realloc.
>
> ======ERROR MSG OUTPUT==============
> $ R CMD SHLIB callcdeclcall.cpp
> making callcdeclcall.d from callcdeclcall.cpp
> In file included from
> c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/objbase.h:73,
>                  from
> c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/ole2.h:9,
>                  from
> c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/windows.h:111,
>                  from callcdeclcall.cpp:4:
> c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/objidl.h:532:45:
> macro "Realloc" requires 3 arguments, but only 2 given
> make: *** [callcdeclcall.d] Error 1
> ======END ERROR MSG OUTPUT==============
>
> Headers in CPP file are:
> #include <R.h>
> #include <Rinternals.h>
> #include <Rdefines.h>
> #include <windows.h>
> #include <cstdio>
>
> Thanks,
>
> Tom
>
>
> On Wed, 22 Nov 2006 21:21:15 -0000, Prof Brian Ripley
> <ripley at stats.ox.ac.uk> wrote:
>
>> Where exactly did you get windows.h from? The recommended source is
>> w32api-3.7.tar.gz, and there is no Ralloc in any of its header files,
>> including objidl.h.
>>
>> BTW, do you know about defining WIN32_LEAN_AND_MEAN when including
>> windows.h?  If not, it is worth finding out about.
>>
>>
>> On Wed, 22 Nov 2006, Tom McCallum wrote:
>>
>>> Hi everyone,
>>>
>>> Have been trying to include windows.h (from MinGW) and R.h into a
>>> package
>>> and have found that Ralloc is coming up as a clash no matter which
>>> include
>>> ordering I use.  In windows it has 2 arguments and is defined in
>>> objidl.h
>>> and in R.h it is 3 arguments.  Any ideas of how to work round this?
>>> Have
>>> checked the web and have not seen anyone else comment on this.
>>
>
>
>

-- 
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



[Rd] Ralloc clash
Prof Brian Ripley