Expected argument 1 of type uint8_t, but got Fixnum 7

On our project, which is primarily written in C++, I have the above
problem in our Ruby bindings. We generate a simple Ruby API using SWIG
[1] and I maintain a more Ruby-like layer on top of that.

One of our APIs, in C++, expects to take in a uint8_t type as an
argument. In the Ruby code I’m not sure what type should be passed in. A
Fixnum results in $SUBJECT (the value I used was 7) and I’m not sure how
to force the value to be something only 8 bits in length.

Any suggestions?

On Tue, Jan 3, 2012 at 3:23 PM, Darryl L. Pierce [email protected]
wrote:

On our project, which is primarily written in C++, I have the above
problem in our Ruby bindings. We generate a simple Ruby API using SWIG
[1] and I maintain a more Ruby-like layer on top of that.

One of our APIs, in C++, expects to take in a uint8_t type as an
argument. In the Ruby code I’m not sure what type should be passed in. A
Fixnum results in $SUBJECT (the value I used was 7) and I’m not sure how
to force the value to be something only 8 bits in length.

Any suggestions?

There are some macros and functions for conversion, IIRC in ruby.h.

Kind regards

robert

On Tue, Jan 3, 2012 at 4:23 PM, Darryl L. Pierce [email protected]
wrote:

One of our APIs, in C++, expects to take in a uint8_t type as an
argument. In the Ruby code I’m not sure what type should be passed in. A
Fixnum results in $SUBJECT (the value I used was 7) and I’m not sure how
to force the value to be something only 8 bits in length.

Any suggestions?

NUM2CHR in ruby.h. I don’t think it distinguishes between signed and
unsigned however.

HTH,
Ammar

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs