cppcheckR: Check a C/C++ file or a folder

View source: R/cppcheckR.R

cppcheckRR Documentation

Check a C/C++ file or a folder

Description

HTML widget which runs Cppcheck.

Usage

cppcheckR(
  path,
  std = NULL,
  def = NULL,
  undef = NULL,
  checkConfig = FALSE,
  height = NULL,
  elementId = NULL
)

Arguments

path

path to a C/C++ file or to a folder containing C/C++ files

std

the standard, one of "c89", "c99", "c11", "c++03", "c++11", "c++14", "c++17", "c++20"; if NULL, you will be prompted to select it

def

character vector of symbols you want to define, e.g. "__cplusplus" or "DEBUG=1"; if NULL, you will be prompted to enter them; set def=NA if you don't want to define any symbol

undef

character vector of symbols you want to undefine; if NULL, you will be prompted to enter them; set undef=NA if you don't want to undefine any symbol

checkConfig

Boolean, whether to run Cppcheck with the option --check-config; this tells you which header files are missing

height

height in pixels (defaults to automatic sizing)

elementId

an id for the widget, this is usually useless

Value

A htmlwidget object.

Examples

example <- function(file){
  filepath <- system.file("cppexamples", file, package = "cppcheckR")
  lines <- readLines(filepath)
  print(cppcheckR(filepath, std = "c++03", def = NA, undef = NA))
  message(file, ":")
  cat(paste0(format(seq_along(lines)), ". ", lines), sep = "\n")
}
example("memleak.cpp")
example("outofbounds.cpp")
example("unusedvar.cpp")
example("useless.cpp")

cppcheckR documentation built on June 10, 2022, 5:06 p.m.