Run the C preprocessor on file using the provided compiler
Source: R/parse-headers.R
preprocess_header.RdThis function runs the configured C compiler with the -E preprocessor
flag and returns the combined preprocessed output as a single string.
Usage
preprocess_header(file, cc = r_cc(), ccflags = NULL, ...)Arguments
- file
Path to a header file to preprocess.
- cc
(Character) Compiler command to use. If
NULL, resolved viar_cc().- ccflags
(Character) Additional flags to pass to the compiler.
- ...
Arguments passed on to
preprocess_headersdirDirectory where header files will be searched.
recursiveLogical; whether to search recursively.
patternFile name pattern(s) used to identify header files.
Examples
if (FALSE) { # \dontrun{
# Check for a compiler before running an example that invokes the preprocessor
rcc <- treesitter.c::r_cc()
if (nzchar(rcc)) {
rcc_prog <- strsplit(rcc, "\\s+")[[1]][1]
if (nzchar(Sys.which(rcc_prog))) {
tmp <- tempfile("hdr3")
dir.create(tmp)
path <- file.path(tmp, "p.h")
writeLines(c("#define TYPE int", "TYPE foo(TYPE x);"), path)
out <- preprocess_header(path)
grepl("int foo\\(", out)
} else {
message("Skipping preprocess example: compiler not found on PATH")
}
}
} # }