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 8333269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:58:11+00:00 2026-06-09T02:58:11+00:00

I am trying to extend Ruby with a C extension in order to add

  • 0

I am trying to extend Ruby with a C extension in order to add an event hook.

Unfortunately, I get the following error:

timber.c:7: error: expected ‘)’ before ‘event’
timber.c: In function ‘timber_init_event_hook’:
timber.c:15: error: ‘timber_trap’ undeclared (first use in this function)
timber.c:15: error: (Each undeclared identifier is reported only once
timber.c:15: error: for each function it appears in.)
timber.c: At top level:
timber.c:21: error: expected ‘)’ before ‘event’
make: *** [timber.o] Error 1

The code I have written:

#include <ruby.h>
#include </Users/paulengel/.rvm/src/ruby-1.9.2-p180/node.h> // #include <node.h> raises `error: node.h: No such file or directory`

// Declarations

static void timber_init_event_hook();
static void timber_trap(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass);
VALUE timber_start(VALUE self);
void Init_timber();

// Definitions

static void timber_init_event_hook() {
  #if defined(RB_EVENT_HOOKS_HAVE_CALLBACK_DATA) || defined(RUBY_EVENT_VM)
    rb_add_event_hook(timber_trap, RUBY_EVENT_CALL | RUBY_EVENT_RETURN | RUBY_EVENT_C_CALL | RUBY_EVENT_C_RETURN, 0);
  #else
    rb_add_event_hook(timber_trap, RUBY_EVENT_CALL | RUBY_EVENT_RETURN | RUBY_EVENT_C_CALL | RUBY_EVENT_C_RETURN);
  #endif
}

static void timber_trap(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass) {
  rb_funcall(rb_mKernel, rb_intern("puts"), 1, rb_str_new2(event));
}

VALUE timber_start(VALUE self) {
  // Do something
}

void Init_timber() {
  VALUE mTimber = rb_define_module("Timber");
  timber_init_event_hook();
  rb_define_singleton_method(mTimber, "start", timber_start, 0);
}

Can someone help me out solving this problem? Thanks in advance.

  • 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-06-09T02:58:13+00:00Added an answer on June 9, 2026 at 2:58 am

    EDIT: Try naming your rb_event_t something other than event. Even though I’m almost positive it’s not a C keyword, the compile error you’re getting seems to be consistent with that type of problem.

    EDIT EDIT: Apparently not the actual problem, but it definitely looks like the error is on those two lines.

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

Sidebar

Related Questions

So I am trying extend the base Application class and add member variables to
I've been trying to extend SimplePie to sort a feed in reverse order. The
I'm trying to extend jQuery with the following: $.fn.extend({ initCore: $.fn.init, init: function (selector,
I'm trying to extend a form and add an upload file field from within
I trying to extend ConuntDownTimer to add the methods pause and resume in this
I'm trying to extend one of my WebApps using IronPython, unfortunately the code below
I'm trying to extend the DropDownList control to simply add one extra property. Code
Newbie to Ruby on Rails and Twitter Bootstrap :P Trying to add a popover
I am trying to extend the ruby string class like this: String.class_eval do def
I'm trying to extend localStorage w/ the following... localStorage.prototype.setItem2 = function(key,value) { localStorage.setItem(key,value); }

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.