From murdoch at stats.uwo.ca  Wed Mar 16 15:42:30 2005
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Wed Mar 16 15:42:30 2005
Subject: [Rd] function-like macros undefined
In-Reply-To: <C698D707214E6F4AB39AB7096C3DE5A58FF437@phost015.EVAFUNDS.intermedia.net>
References: <C698D707214E6F4AB39AB7096C3DE5A58FF437@phost015.EVAFUNDS.intermedia.net>
Message-ID: <94hg31lqon7m2a7q4729gvb5g9578dbfst@4ax.com>

On Tue, 15 Mar 2005 18:58:32 -0800, "Vadim Ogranovich"
<vograno@evafunds.com> wrote :

>Hi,
> 
>Somehow function-like macros from Rinternals.h are not defined when I
>include the file.
> 
>foo.c
>##################
>#include <R.h>
>#include <Rinternals.h>
> 
>
>#ifndef NILSXP
>#error("NILSXP")
>#endif
> 
>
>#ifndef INTEGER
>#error("INTEGER")
>#endif
>###################
>
> 
>When compiled:
>vor/src% gcc -I/usr/local/lib/R/include  -g -O2 -c foo.c -o foo.o
>foo.c:11:2: #error ("INTEGER")
>
>Note that NILSXP is defined. This is true for some other function-like
>macros, e.g. RAW()

The definition of INTEGER is wrapped in 

#ifdef USE_RINTERNALS

and there's this comment in Defn.h:

/* To test the write barrier used by the generational collector,
   define TESTING_WRITE_BARRIER.  This makes the internal structure of
   SEXPRECs visible only inside of files that explicitly define
   USE_RINTERNALS, and all uses of SEXPREC fields that do not go
   through the appropriate functions or macros will become compilation
   errors.  Since this does impose a small but noticable performance
   penalty, code that includes Defn.h (or code that explicitly defines
   USE_RINTERNALS) can access a SEXPREC's fields directly. */

To read about the reasons for the write barrier, see

http://www.stat.uiowa.edu/~luke/R/barrier.html

Duncan Murdoch
> 
> 
>Did anyone come across such a problem?
> 
>> version
>         _                       
>platform x86_64-unknown-linux-gnu
>arch     x86_64                  
>os       linux-gnu               
>system   x86_64, linux-gnu       
>status                           
>major    2                       
>minor    0.1                     
>year     2004                    
>month    11                      
>day      15                      
>language R                       
>
> 
>OS: suse.9.2_64
> 
>Note also that R doesn't recognize this is Suse, it says
>x86_64-unknown-linux-gnu. Hope this is not a problem.
> 
>Thanks,
>Vadim
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-devel@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] function-like macros undefined
Duncan Murdoch