OS Manuals

/usr/bin/stanc

The Stan compiler — translates Stan probabilistic programs to C++

From stanc3 2.40.0-r0 (enterprise-packages), captured 2026-11-08 by running stanc --help (exit 0). permalink

NAME
       stanc - compile Stan programs to C++

SYNOPSIS
       stanc [OPTION]… [MODEL_FILE]

DESCRIPTION
       The Stan compiler (also known as stanc or stanc3) reads a Stan file
       and compiles it to C++. It also allows for other Stan program
       manipulation like formatting (--auto-format) and introspection
       (--info).

       For more information on Stan, see https://mc-stan.org.

       For more documentation on the compiler for users, see
       https://mc-stan.org/docs/stan-users-guide/using-stanc.html.

       For more information on the compiler for developers, see
       https://mc-stan.org/stanc3/stanc/.

ARGUMENTS
       MODEL_FILE
           The Stan model file to compile. This should be a file ending in
           .stan or .stanfunctions (which automatically sets
           --standalone-functions), or '-' to read from standard input.

OPTIONS
       -? [=FMT] (default=auto)
           Synonym for --help.

       --allow-undefined
           Do not fail if a function is declared but not defined. This
           usually means the definition will be provided later as a C++
           function.

       --auto-format
           Output a formatted version of the Stan program. The output can be
           tweaked using --max-line-length and --canonicalize.

       --canonicalize=OPTIONS
           Enable specific canonicalizations in a comma separated list.
           Options are 'deprecations', 'parentheses', 'braces', 'includes',
           'strip-comments'.

       --color=WHEN (absent=auto or STANC_COLORS env)
           Colorize the output. WHEN must be one of auto, always or never.

       --filename-in-msg=FILENAME (absent=MODEL_FILE)
           Sets the filename used in compiler and runtime errors.

       --help[=FMT] (default=auto)
           Show this help in format FMT. The value FMT must be one of auto,
           pager, groff or plain. With auto, the format is pager or plain
           whenever the TERM env var is dumb or undefined.

       -I DIRS, --include-paths=DIRS (absent="")
           A comma-separated list of directories which are searched whenever
           an #include directive is parsed.

       --info
           If set, print information about the model.

       --max-line-length=LENGTH (absent=78)
           Set the maximum line length for the formatter.

       --name=NAME (absent=MODEL_FILE_NAME_model)
           Take a string to set as the model name. This controls the
           namespace in the generated C++.

       -o FILENAME, --output=FILENAME
           Output file for generated C++ code (default =
           "MODEL_FILE_NAME.hpp") or auto-formatting output (default: no
           file/print to stdout).

       --O0
           (Default) Do not apply optimizations to the Stan code.

       --O1
           Only basic optimizations are applied. Recommended. The deprecated
           option --O is aliased to this starting in Stan 2.37.

       --Oexperimental
           (Experimental) Apply all compiler optimizations. Some of these are
           not thorougly tested and may not always improve a programs
           performance.

       --print-canonical
           Prints the canonicalized program. Equivalent to --auto-format
           --canonicalize=deprecations,includes,parentheses,braces.

       --print-cpp
           If set, output the generated C++ Stan model class to stdout.

       --standalone-functions
           If set, the generated C++ will only contain the code for the
           functions in the functions block, not the full Stan model class.

       --use-opencl
           If set, try to use matrix_cl signatures for supported Stan Math
           functions.

       --version
           Show version information.

       --warn-pedantic
           Emit warnings about common mistakes in Stan programs. Note: This
           may produce false positive warnings.

       --warn-uninitialized
           (Experimental) Emit warnings about uninitialized variables.

COMMANDS
       The following flags will cause the compiler to exit after printing
       information. No MODEL_FILE is required.

       --dump-stan-math-distributions
           Dump out the list of supported probability distributions and their
           supported suffix types for the Stan Math backend.

       --dump-stan-math-signatures
           Dump out the list of supported function signatures the for Stan
           Math backend.

EXTRA OPTIONS
       These flags are provided primarily for development and debugging;
       their exact behavior should not be relied on.

       --debug-ast
           For debugging purposes: print the undecorated AST, before semantic
           checking.

       --debug-data-file=JSON_FILE
           Provide (possibly partially specified) data block values for use
           with --debug-generate-data or --debug-generate-inits.

       --debug-decorated-ast
           For debugging purposes: print the decorated AST, after semantic
           checking.

       --debug-generate-data
           For debugging purposes: generate a mock dataset to run the model
           on.

       --debug-generate-inits
           For debugging purposes: generate a mock initial value for each
           parameter.

       --debug-lex
           For debugging purposes: print the lexer actions.

       --debug-lir
           For debugging purposes: print the C++ LIR as a s-expression.
           Mainly for comparison with --print-cpp.

       --debug-mem-patterns
           For debugging purposes: print a list of matrix variables and their
           memory type, either AoS (array of structs) or the more efficient
           SoA (struct of arrays). Only has an effect when optimizations are
           turned on.

       --debug-mir
           For debugging purposes: print the MIR after lowering.

       --debug-mir-pretty
           For debugging purposes: pretty-print the MIR after lowering.

       --debug-optimized-mir
           For debugging purposes: print the MIR after it's been optimized.
           Only has an effect when optimizations are turned on.

       --debug-optimized-mir-pretty
           For debugging purposes: pretty-print the MIR after it's been
           optimized. Only has an effect when optimizations are turned on.

       --debug-parse
           For debugging purposes: print the parser actions.

       --debug-print-factor-graph
           For debugging purposes: print a conservative over-approximation of
           the factor graph for the model(s) implemented in the Stan program.

       --debug-transformed-mir
           For debugging purposes: print the MIR after the backend has
           transformed it.

       --debug-transformed-mir-pretty
           For debugging purposes: pretty-print the MIR after the backend has
           transformed it.

       -f SETTING
           Debugging features. Valid values: -fsoa to force on the Struct of
           Arrays optimization. -fno-soa to force it off.

EXIT STATUS
       0   on success.

       1   on compilation failure.

       124 on command line parsing errors.

       125 on internal compiler errors. Please file a bug!

ENVIRONMENT
       These environment variables affect the execution of stanc:

       STANC_COLORS
           See option --color.

BUGS
       Please report at https://github.com/stan-dev/stanc3/issues.
Options (38)
OptionDescriptionSource
--allow-undefinedDo not fail if a function is declared but not defined.help
--auto-formatOutput a formatted version of the Stan program.help
--canonicalize OPTIONSEnable specific canonicalizations in a comma separated list.help
--filename-in-msg FILENAMESets the filename used in compiler and runtime errors.help
--help FMTShow this help in format FMT.help
--infoIf set, print information about the model.help
--max-line-length LENGTHSet the maximum line length for the formatter.help
--name NAMETake a string to set as the model name.help
-o, --output FILENAMEOutput file for generated C++ code (default = "MODEL_FILE_NAME.hpp") or auto-formatting output (default: no file/print to stdout).help
--O0(Default) Do not apply optimizations to the Stan code.help
--O1Only basic optimizations are applied.help
--Oexperimental(Experimental) Apply all compiler optimizations.help
--print-canonicalPrints the canonicalized program.help
--print-cppIf set, output the generated C++ Stan model class to stdout.help
--standalone-functionsIf set, the generated C++ will only contain the code for the functions in the functions block, not the full Stan model class.help
--use-openclIf set, try to use matrix_cl signatures for supported Stan Math functions.help
--versionShow version information.help
--warn-pedanticEmit warnings about common mistakes in Stan programs.help
--warn-uninitialized(Experimental) Emit warnings about uninitialized variables.help
--dump-stan-math-distributionsDump out the list of supported probability distributions and their supported suffix types for the Stan Math backend.help
--dump-stan-math-signaturesDump out the list of supported function signatures the for Stan Math backend.help
--debug-astFor debugging purposes: print the undecorated AST, before semantic checking.help
--debug-data-file JSON_FILEProvide (possibly partially specified) data block values for use with --debug-generate-data or --debug-generate-inits.help
--debug-decorated-astFor debugging purposes: print the decorated AST, after semantic checking.help
--debug-generate-dataFor debugging purposes: generate a mock dataset to run the model on.help
--debug-generate-initsFor debugging purposes: generate a mock initial value for each parameter.help
--debug-lexFor debugging purposes: print the lexer actions.help
--debug-lirFor debugging purposes: print the C++ LIR as a s-expression.help
--debug-mem-patternsFor debugging purposes: print a list of matrix variables and their memory type, either AoS (array of structs) or the more efficient SoA (struct of arrays).help
--debug-mirFor debugging purposes: print the MIR after lowering.help
--debug-mir-prettyFor debugging purposes: pretty-print the MIR after lowering.help
--debug-optimized-mirFor debugging purposes: print the MIR after it's been optimized.help
--debug-optimized-mir-prettyFor debugging purposes: pretty-print the MIR after it's been optimized.help
--debug-parseFor debugging purposes: print the parser actions.help
--debug-print-factor-graphFor debugging purposes: print a conservative over-approximation of the factor graph for the model(s) implemented in the Stan program.help
--debug-transformed-mirFor debugging purposes: print the MIR after the backend has transformed it.help
--debug-transformed-mir-prettyFor debugging purposes: pretty-print the MIR after the backend has transformed it.help
-f SETTINGDebugging features.help

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.