Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Bug with Ruby 2.3 #538

Open
gtamba opened this issue Aug 22, 2016 · 5 comments
Open

API Bug with Ruby 2.3 #538

gtamba opened this issue Aug 22, 2016 · 5 comments

Comments

@gtamba
Copy link

gtamba commented Aug 22, 2016

I was having this issue when I tried testing my gem on Ruby 2.3 and greater. The gem adds the nmatrix.h header to the native include path so that NMatrix objects can be created directly from C code. There is no problem with running NMatrix outside on a terminal or ruby scripts, it's just a macro clash that occurs when SpiceRub is building

In file included from ../../../../ext/spice_rub/spice_ephemerides.h:5:0,
                 from ../../../../ext/spice_rub/spice_ephemerides.c:1:
/home/gaurav/.rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/nmatrix-0.2.1/nmatrix.h:72:1: error: redefinition of ‘rb_array_const_ptr’
 rb_array_const_ptr(VALUE a)
 ^
In file included from /home/gaurav/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/ruby.h:33:0,
                 from ../../../../ext/spice_rub/spice_ephemerides.h:1,
                 from ../../../../ext/spice_rub/spice_ephemerides.c:1:
/home/gaurav/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/ruby/ruby.h:2018:1: note: previous definition of ‘rb_array_const_ptr’ was here
 rb_array_const_ptr(VALUE a)
 ^
make: *** [spice_ephemerides.o] Error 1
rake aborted!

This is the code from extconf.rb that locates the nmatrix header :-

nmatrix_path =  Gem::Specification.find_all_by_name("nmatrix")

nmatrix_header_dir = nmatrix_path.compact[0].require_path

HEADER_DIRS = [File.expand_path(File.join(File.dirname(__FILE__), "cspice/include")), nmatrix_header_dir]
@translunar
Copy link
Member

Believe this is a duplicate of #522.

@translunar
Copy link
Member

@gau27 Can you do the following, please?

rake clobber
rake compile

And look at the output, see if it finds rb_array_const_ptr() (and let me know).

Then look in the nmatrix_config.h file that gets generated (mine is in tmp/x86_64-darwin15/nmatrix/2.3.1) and paste it here?

@gtamba
Copy link
Author

gtamba commented Aug 25, 2016

@MohawkJohn I'm unable to replicate the issue as in #522 , build works fine for just the NMatrix source. Only when I try to compile SpiceRub is this error showing up

@gtamba
Copy link
Author

gtamba commented Aug 25, 2016

Can confirm that this problem arises when trying to compile SpiceRub with NMatrix built from source as well as from Rubygems for Rubies 2.3.0, 2.3.1. As Prasun said, removing the following lines from nmatrix.h seems to solve the issue without breaking any tests of NMatrix or SpiceRub. I have no idea how this will impact previous versions though.

#ifndef HAVE_RB_ARRAY_CONST_PTR
static inline const VALUE *
rb_array_const_ptr(VALUE a)
{
  return FIX_CONST_VALUE_PTR((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ?
    RARRAY(a)->as.ary : RARRAY(a)->as.heap.ptr);
}
#endif

@translunar
Copy link
Member

Bumping this since there's a proposed solution here, and it's relatively easy to test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants