Any simple working example of external C++ lpdf function?

I found the source of the truncated error messages in inline’s compileCode function (https://github.com/eddelbuettel/inline/blob/master/R/cfunction.R).

It truncates the error messages if they are more than the warning.length size (default 1000). Setting the size to the max warning.length size of 8100 doesn’t help because it is not enough. The stop() function also truncates the error messages if the length is more than the warning.length.

One workaround I found is to change the following lines near the end of compileCode function:

    if ( verbose ) {
      writeLines(errmsg)
    }
    else if ( sum(nchar(errmsg)) > getOption("warning.length") ) {
      stop(tail(errmsg))
    }
    else stop(errmsg)

Another is to comment out unlink( errfile ) and set the tempdir to the current working directory using https://rdrr.io/github/s-u/unixtools/man/set.tempdir.html. The complete error messages can then be read from the error file.

1 Like