[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: Re: Strange behaviour of rb_ary_entry
From: Jean-Hugues Kabuiku <amazinggaijin () gmail ! com>
Date: 2015-08-23 17:35:04
Message-ID: CAKmMcUq_bDCRcLaoCz3f33QyFdij1-QKfSBzOWyhXHAG0oyJDA () mail ! gmail ! com
[Download RAW message or body]
How to unsubscribe to this list?
On 23 Aug 2015 15:04, "Mikael Hakman" <mhakman@dkab.net> wrote:
> Hello,
>
> I'm using C inline capabilities. I get very strange results from
> rb_ary_entry function. Here is the test program:
>
> require "inline"
> class Test
> inline do |xtest|
> xtest.add_compile_flags('-std=c11')
> xtest.c_singleton '
> void run (VALUE arr) {
> for (int i = 0; i < RARRAY_LEN(arr); i++) {
> printf ("%d %ld\n",i,(long)rb_ary_entry (arr,(long)i));
> }
> }
> '
> end
> end
> arr = [0,1,2,3,4,5,6,7,8,9]
> Test.run arr
>
> The expected output is:
> 0 0
> 1 1
> 2 2
> 3 3
> 4 4
> 5 5
> 6 6
> 7 7
> 8 8
> 9 9
>
> Instead I get the following:
> 0 1
> 1 3
> 2 5
> 3 7
> 4 9
> 5 11
> 6 13
> 7 15
> 8 17
> 9 19
>
> What can be wrong?
>
> Thanks/Mikael
>
>
[Attachment #3 (text/html)]
<p dir="ltr">How to unsubscribe to this list?</p>
<div class="gmail_quote">On 23 Aug 2015 15:04, "Mikael Hakman" <<a \
href="mailto:mhakman@dkab.net">mhakman@dkab.net</a>> wrote:<br \
type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br> <br>
I'm using C inline capabilities. I get very strange results from rb_ary_entry \
function. Here is the test program:<br> <br>
require "inline"<br>
class Test<br>
inline do |xtest|<br>
xtest.add_compile_flags('-std=c11')<br>
xtest.c_singleton '<br>
void run (VALUE arr) {<br>
for (int i = 0; i < RARRAY_LEN(arr); i++) {<br>
printf ("%d %ld\n",i,(long)rb_ary_entry (arr,(long)i));<br>
}<br>
}<br>
'<br>
end<br>
end<br>
arr = [0,1,2,3,4,5,6,7,8,9]<br>
Test.run arr<br>
<br>
The expected output is:<br>
0 0<br>
1 1<br>
2 2<br>
3 3<br>
4 4<br>
5 5<br>
6 6<br>
7 7<br>
8 8<br>
9 9<br>
<br>
Instead I get the following:<br>
0 1<br>
1 3<br>
2 5<br>
3 7<br>
4 9<br>
5 11<br>
6 13<br>
7 15<br>
8 17<br>
9 19<br>
<br>
What can be wrong?<br>
<br>
Thanks/Mikael<br>
<br>
</blockquote></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic