Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7429051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:54:31+00:00 2026-05-29T08:54:31+00:00

I am trying to rewrite a highly recursive function using inline C with Ruby.

  • 0

I am trying to rewrite a highly recursive function using inline C with Ruby. The function accepts an undefined number of arguments, i.e. it would look like this in Ruby:

    def each_entity(*types)
      # Do something and recurse.
    end

I am trying to mimick this in inline C using the following code:

    VALUE each_entity_c(int argc, VALUE *argv)
    {
      // ...
    }

But this yields the compile error:

inline.rb:486:in `ruby2c': Unknown type "VALUE *" (ArgumentError)

Is this the correct way to accomplish this in C? If so, what could have caused this error? If not, how is it done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:54:32+00:00Added an answer on May 29, 2026 at 8:54 am

    Instead of using builder.c, try builder.c_raw (or builder.c_raw_singleton) when defining your methods. You might want to add VALUE self to the end of the args list, but it seems to work with or without in my tests. It might also be worth explicitly specifying the arity, just to be safe:

    inline do |builder|
    
      builder.c_raw <<-EOS, :arity => -1
        VALUE each_entity_c(int argc, VALUE *argv, VALUE self)
        {
          // ...
        }
      EOS
    end
    

    Using builder.c, Ruby Inline will rewrite the function so that it accepts Ruby VALUE types as parameters, and add code to convert these to the c types in your original. You’re writing code that already expects VALUE arguments so don’t want this conversion to be done, so you need to use c_raw.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to rewrite some legacy C code and would like to have
I am trying to rewrite URLs using mod_rewrite. It is enabled in httpd.conf and
I am trying to rewrite a URL using .htaccess. I am running on Apache
I'm trying to rewrite some query strings I have in my URL like this
I'm using Isapi Rewrite 3 (mod rewrite clone for IIS) and trying to rewrite
I am trying to rewrite url from www.xxx.com/test.com to www.xxx.com/my.php?d=test.com using the following directive:
I am trying to rewrite tagged.php?flag=parameter&page=1 into /parameter/?page=1 So I am using: RewriteRule Hotties/?(.*)
I am trying to rewrite a url to a different one by using inbound
I'm trying to rewrite a Mootools tooltip class in JQuery using this class plugin
I'm trying to rewrite this url: http://www.example.com/user.php?user=username into http://example.com/username I'm using this code in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.