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.