STANC(1)
π STANC(1) β like, the Stanc Manual, bestie β¨
okay so real talk: this is the manual page for stanc, and I'm gonna walk you through it like we're texting at 1am π«Ά it's literally the Stan compiler (aka stanc or stanc3), and I promise it's not scary.
πΈ NAME πΈ
stanc β compile Stan programs to C++ π₯
β¨ SYNOPSIS β¨
stanc [OPTION]β¦ [MODEL_FILE]
π¦ DESCRIPTION π¦
So the Stan compiler β which honestly goes by stanc or stanc3, pick your fave π
β reads a Stan file and compiles it to C++. That's the main character job. But it ALSO does other Stan program manipulation, like formatting (--auto-format) and introspection (--info). Versatile queen π.
Wanna know more about Stan in general? https://mc-stan.org β go look, it's giving documentation.
More docs on the compiler, like, for users? https://mc-stan.org/docs/stan-users-guide/using-stanc.html π
And for the devs, more compiler info lives at %%PKG_DOC%% π§
π ARGUMENTS π
MODEL_FILEβ the Stan model file you want to compile. It should be a file ending in.stanor.stanfunctions(and ooooh, ending in.stanfunctionsautomatically sets--standalone-functionsfor you, slay β¨), or you can pass'-'to read from standard input π
π OPTIONS π
okay this is the long part, stay with me, we're gonna get through it together π«Ά
-?[=FMT] (default=auto) β literally just a synonym for--help. same vibe, different key π--allow-undefinedβ don't fail if a function is declared but not defined. usually that means the definition is gonna show up later as a C++ function, so like, it's fine, it's handled π--auto-formatβ outputs a formatted version of the Stan program. you can tweak that output with--max-line-lengthand--canonicalizeβ¨--canonicalize=OPTIONSβ turn on specific canonicalizations in a comma separated list. the options are'deprecations','parentheses','braces','includes','strip-comments'π§--color=WHEN(absent=auto or STANC_COLORS env) β colorize the output.WHENhas to be one ofauto,alwaysornever. aesthetic decisions are valid π--filename-in-msg=FILENAME(absent=MODEL_FILE) β sets the filename used in compiler and runtime errors π--help[=FMT](default=auto) β shows this help in formatFMT.FMTmust be one ofauto,pager,grofforplain. withauto, the format ispagerorplainwhenever theTERMenv var isdumbor undefined π-IDIRS,--include-paths=DIRS(absent="") β a comma-separated list of directories that get searched whenever an#includedirective is parsed. like a little scavenger hunt for includes π--infoβ if set, print information about the model π--max-line-length=LENGTH(absent=78) β sets the max line length for the formatter. 78 is the default, no cap π--name=NAME(absent=MODEL_FILE_NAME_model) β takes a string and sets it as the model name. this controls the namespace in the generated C++ π·οΈ-oFILENAME,--output=FILENAMEβ output file for generated C++ code (default ="MODEL_FILE_NAME.hpp") or for auto-formatting output (default: no file/print to stdout) πΎ--O0β (Default) do not apply optimizations to the Stan code. it's giving unbothered π--O1β only basic optimizations are applied. Recommended β also: the deprecated option--Ois aliased to this starting in Stan 2.37, so heads up π«Ά--Oexperimentalβ (Experimental) apply ALL compiler optimizations. some of these are not thorougly tested and may not always improve a program's performance. it's giving risky behavior, don't say I didn't warn you π--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. minimalism, we love her π--use-openclβ if set, try to usematrix_clsignatures 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, so like, don't spiral π--warn-uninitializedβ (Experimental) emit warnings about uninitialized variables π
π COMMANDS π
these flags make the compiler exit right after printing info. no MODEL_FILE required, bestie, you can just run them π«Ά
--dump-stan-math-distributionsβ dumps out the list of supported probability distributions and their supported suffix types for the Stan Math backend π--dump-stan-math-signaturesβ dumps 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. like, fr fr, don't build your whole thing on these π
--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-dataor--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 π-fSETTING β debugging features. valid values:-fsoato force on the Struct of Arrays optimization,-fno-soato force it off π¨
π EXIT STATUS π
0β on success. we love a happy ending π1β on compilation failure π124β on command line parsing errors π«125β on internal compiler errors. Please file a bug! like genuinely, tell them, they wanna know π
π ENVIRONMENT π
these environment variables affect how stanc runs:
STANC_COLORSβ see option--colorπ¨
π BUGS π
please report at %%PKG_ISSUES%% π don't suffer in silence, bestie π«Ά
okay that's the whole thing! and for the cute sign-off: this page is from Stanc stanc3 v2.40.0 (Unix) β that's the source/version you're looking at, mwah π go compile something iconic πβ¨
π¦ where this page comes from
- nixpkgs unstable: ocaml5.5.1-stanc 2.40.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms