Re: [Rd] Ralloc clash

From: Tom McCallum <tom.mccallum_at_levelelimited.com>
Date: Thu 23 Nov 2006 - 11:52:46 GMT

But from R_ext/RS.h you have (my comments are given by <-- some text):

====================================BEGIN  
EXTRACT====================================================
#ifndef STRICT_R_HEADERS  							<-- fair enough this is defined but it  
ends ...

#define R_PROBLEM_BUFSIZE 4096
/* Parentheses added for FC4 with gcc4 and -D_FORTIFY_SOURCE=2 */

#define PROBLEM                 {char  
R_problem_buf[R_PROBLEM_BUFSIZE];(sprintf)(R_problem_buf,
#define MESSAGE                 {char  
R_problem_buf[R_PROBLEM_BUFSIZE];(sprintf)(R_problem_buf,
#define ERROR                   ),error(R_problem_buf);}
#define RECOVER(x)              ),error(R_problem_buf);}
#define WARNING(x)              ),warning(R_problem_buf);}
#define LOCAL_EVALUATOR         /**/
#define NULL_ENTRY              /**/
#define WARN                    WARNING(NULL)

#endif 												<-- ifndef clause ends here

/* S Like Memory Management */

extern void *R_chk_calloc(size_t, size_t); extern void *R_chk_realloc(void *, size_t); extern void R_chk_free(void *);

#define Calloc(n, t) (t *) R_chk_calloc( (size_t) (n), sizeof(t) ) #define Realloc(p,n,t) (t *) R_chk_realloc( (void *)(p), (size_t)((n) * sizeof(t)) ) <-- This is still defined therefore, is it not?

/* S-PLUS 3.x but not 5.x NULLs the pointer in the following */

#ifndef STRICT_R_HEADERS
#define Free(p)        (R_chk_free( (void *)(p) ), (p) = NULL)
#endif
#define R_Free(p)      (R_chk_free( (void *)(p) ), (p) = NULL)

#define Memcpy(p,q,n) memcpy( p, q, (size_t)( (n) * sizeof(*p) ) )

====================================END  
EXTRACT====================================================

The STRICT_R_HEADERS does not go around the Realloc function so even with STRICT_R_HEADERS defined the problem persists.   To test I placed "#define STRICT_R_HEADERS" at the top of my single cpp file before all the include lines as I am not sure how to pass the -D function through to the g++ when doing R CMD SHLIB - would putting it in one of the PKG_ environment variables work - if so which?

Tom

On Thu, 23 Nov 2006 11:13:44 -0000, Prof Brian Ripley <ripley@stats.ox.ac.uk> wrote:

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

-- 
Dr. Thomas McCallum
Systems Architect,
Level E Limited
ETTC, The King's Buildings
Mayfield Road,
Edinburgh EH9 3JL, UK
Work  +44 (0) 131 472 4813
Fax:  +44 (0) 131 472 4719
http://www.levelelimited.com
Email: tom@levelelimited.com

Level E is a limited company incorporated in Scotland. The c...{{dropped}}

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Thu Nov 23 22:56:00 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 23 Nov 2006 - 14:30:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.