I have a function in C that gets run from R via .Call and the boolean parameter always gets evaluated as true. Here's a minimal reproducible example:
library(inline)
dummy <- cfunction(signature(x = "bool"),
body = '
int val = x?0:1;
SEXP fake = allocVector(LGLSXP, 5);
SEXP ans = allocVector(LGLSXP, val);
if (val== 1) {
return fake;
}
return ans;
')
dummy(FALSE)
dummy(TRUE)
Both of these function calls return logical(0)