Fandom

Ruby Wiki

C API/Boolean values

< C API

26pages on
this wiki
Add New Page
Talk0 Share

C API functions can accept or return boolean values of Qtrue or Qfalse. These can be converted to and from a C program's idea of true and false as follows:

  • To convert a VALUE to a C boolean, use RTEST(val);. This evaluates as false if val is Qfalse or Qnil, and true otherwise.
  • To convert a C boolean to a VALUE, use flag ? Qtrue : Qfalse.

dl.h has a macro INT2BOOL that converts a C boolean to a VALUE; but it is not clear that dl.h is meant to be used in extensions.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.