[Rd] Problem with types on 64-bit

2007-02-22 Thread tom
Hi Everyone,

I have a problem using some working 32-bit R code with 64-bit machine ( I am
using version R-2.4.1 ).  The problem occurs when I am trying to detect a NULL
STRSXP type. ( Perhaps I am doing this detection in the wrong way? )

On 32-bit the following works, and correctly identifies if I am passing NULL
or a valid string object:

if ( v_dta_start != R_NilValue  STRING_ELT( v_dta_start, 0 ) != R_NilValue )
{
dta.start = CHAR( STRING_ELT( v_dta_start, 0 ) );
}

Yet on a 64-bit machine I get the following errors:

(1) when I pass NULL it goes into the if clause and then when it tries to set
dta.start it displays:
CHAR() can only be applied to a 'CHARSXP', not a 'NULL'
(2) if I pass a valid string such as hello, I get the following:
CHAR() can only be applied to a 'CHARSXP', not a 'character'

I have tried converting using AS_CHARACTER but that just brings up the same
messages.  I have also seen S4 and PROMSXP types come up in these error
messages.  

What I don't understand is why this happens - any ideas?

If I can supply any more info let me know, below is the CPU information for
the 64-bit machine. 

Many thanks for your help

Tom

64-BIT CPU INFO
===

processor   : 0
vendor_id   : AuthenticAMD
cpu family  : 15
model   : 5
model name  : AMD Opteron(tm) Processor 144
stepping: 10
cpu MHz : 1794.932
cache size  : 1024 KB
fpu : yes
fpu_exception   : yes
cpuid level : 1
wp  : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov 
pat
pse36 clflush mmx fxsr sse sse2 syscall nx mmxext lm 3dnowext 3dnow
bogomips: 3597.08
TLB size: 1024 4K pages
clflush size: 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Problem with types on 64-bit

2007-02-22 Thread Prof Brian Ripley
Neither NULL nor hello are valid values for an element of a STRSXP: only 
CHARSXPs are.  So your test is not the correct one: you need to test 
both isString(v_dta_start) and  TYPEOF(STRING_ELT( v_dta_start, 0 )) == 
CHARSXP to be really safe.

Calling STRSXP on a random SEXP is likely to give different results on 
different machines: there is no fundamental 32- vs 64-but difference here.

On Tue, 20 Feb 2007, [EMAIL PROTECTED] wrote:

 Hi Everyone,

 I have a problem using some working 32-bit R code with 64-bit machine ( I am
 using version R-2.4.1 ).  The problem occurs when I am trying to detect a NULL
 STRSXP type. ( Perhaps I am doing this detection in the wrong way? )

 On 32-bit the following works, and correctly identifies if I am passing NULL
 or a valid string object:

 if ( v_dta_start != R_NilValue  STRING_ELT( v_dta_start, 0 ) != R_NilValue )
 {
dta.start = CHAR( STRING_ELT( v_dta_start, 0 ) );
 }

 Yet on a 64-bit machine I get the following errors:

 (1) when I pass NULL it goes into the if clause and then when it tries to set
 dta.start it displays:
 CHAR() can only be applied to a 'CHARSXP', not a 'NULL'
 (2) if I pass a valid string such as hello, I get the following:
 CHAR() can only be applied to a 'CHARSXP', not a 'character'

 I have tried converting using AS_CHARACTER but that just brings up the same
 messages.  I have also seen S4 and PROMSXP types come up in these error
 messages.

 What I don't understand is why this happens - any ideas?

 If I can supply any more info let me know, below is the CPU information for
 the 64-bit machine.

 Many thanks for your help

 Tom

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Problem with types on 64-bit

2007-02-22 Thread Oleg Sklyar
Besides the comments from Prof. Ripley, I am not sure your if statement 
is fully correct, because suppose v_dta_start is R_NilValue -- why then 
STRING_ELT( R_NilValue, 0 ) should be a valid statement in first place? 
In my code I often use R_NilValue to check for R-NULL, but it always 
works fine on both 32 and 64 bits, moreover on Linux, Mac and Windows as 
well... Oleg

[EMAIL PROTECTED] wrote:
 Hi Everyone,
 
 I have a problem using some working 32-bit R code with 64-bit machine ( I am
 using version R-2.4.1 ).  The problem occurs when I am trying to detect a NULL
 STRSXP type. ( Perhaps I am doing this detection in the wrong way? )
 
 On 32-bit the following works, and correctly identifies if I am passing NULL
 or a valid string object:
 
 if ( v_dta_start != R_NilValue  STRING_ELT( v_dta_start, 0 ) != R_NilValue )
 {
 dta.start = CHAR( STRING_ELT( v_dta_start, 0 ) );
 }
 
 Yet on a 64-bit machine I get the following errors:
 
 (1) when I pass NULL it goes into the if clause and then when it tries to set
 dta.start it displays:
 CHAR() can only be applied to a 'CHARSXP', not a 'NULL'
 (2) if I pass a valid string such as hello, I get the following:
 CHAR() can only be applied to a 'CHARSXP', not a 'character'
 
 I have tried converting using AS_CHARACTER but that just brings up the same
 messages.  I have also seen S4 and PROMSXP types come up in these error
 messages.  
 
 What I don't understand is why this happens - any ideas?
 
 If I can supply any more info let me know, below is the CPU information for
 the 64-bit machine. 
 
 Many thanks for your help
 
 Tom
 
 64-BIT CPU INFO
 ===
 
 processor : 0
 vendor_id : AuthenticAMD
 cpu family: 15
 model : 5
 model name: AMD Opteron(tm) Processor 144
 stepping  : 10
 cpu MHz   : 1794.932
 cache size: 1024 KB
 fpu   : yes
 fpu_exception : yes
 cpuid level   : 1
 wp: yes
 flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov 
 pat
 pse36 clflush mmx fxsr sse sse2 syscall nx mmxext lm 3dnowext 3dnow
 bogomips  : 3597.08
 TLB size  : 1024 4K pages
 clflush size  : 64
 cache_alignment   : 64
 address sizes : 40 bits physical, 48 bits virtual
 power management: ts fid vid ttp
 
 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel