CWEB(1)
β¨ NAME β¨
okay bestie, welcome to the CWEB manual page β that's CWEB(1) in the General Commands Manual, and we are so normal about it π
ctangle, cweave β translate CWEB to C/C++ and/or TeX π
π SYNOPSIS π
ctangle [options] webfile[.w] [{changefile[.ch]|-} [outfile[.c]]]
cweave [options] webfile[.w] [{changefile[.ch]|-} [outfile[.tex]]]
πΈ DESCRIPTION πΈ
okay so the ctangle program converts a CWEB source document into a C/C++ program that may be compiled in the usual way. the output file includes #line specifications so that debugging can be done in terms of the CWEB source file. it's giving "i speak fluent compiler AND readable docs" β¨
the cweave program converts the same CWEB file into a TeX file that may be formatted and printed in the usual way. it takes appropriate care of typographic details like page layout and the use of indentation, italics, boldface, etc., and it supplies extensive cross-index information that it gathers automatically. no cap, it's lowkey a whole typesetting glow-up π
CWEB allows you to prepare a single document containing all the information that is needed both to produce a compilable C/C++ program and to produce a well-formatted document describing the program in as much detail as the writer may desire. the user of CWEB ought to be familiar with TeX as well as C/C++. that's the vibe check: two skills, one file, main character energy π
π¦ USAGE π¦
the command line should have one, two, or three names on it.
- the first is taken as the CWEB input file (and
.wis added if there is no extension). - if there's a second name, it is a change file (and
.chis added if there is no extension). the change file overrides parts of the CWEB file, as described in the documentation. it literally goes in and edits the lore π - if there's a third name, it overrides the default name of the output file, which is ordinarily the same as the name of the input file (but on the current directory) with the extension
.tex.
if you just want to change the output file name, but don't have a change file to apply, you can use - as the second argument. tiny hack, huge slay β¨
π DIFFERENCES TO ORIGINAL CWEB π
CWEBbin tries hard to be a drop-in replacement for CWEB, so in general you should not notice any differences in invoking the programs nor in the resulting output. but there are a few differences worth noting, bestie:
- Options
--help,--quiet,--verbose,--version, and flags+c,-i,-o,+u, and+lXare new in CWEBbin and TeX Live. - Option
+lXis accompanied by several wrapper files forcwebmac.texwith translated captions for German (+ld), French (+lf), and Italian (+li). - CWEB in TeX Live operates silently by default (as of 2019); use the
--verboseoption to get the original behavior. - File lookup with the environment variable
CWEBINPUTSis extended to permit several, colon-separated, paths; see ENVIRONMENT below. - If properly configured, the main programs
ctangleandcweaveare localized with the βGNU gettext utilitiesβ.
π OPTIONS π
okay so here's the whole situation. options on the command line may be either turned off with - (if they are on by default) or turned on with + (if they are off by default). in fact, the options are processed from left to right, so a sequence like --verbose -h will only show the banner line (+b) and the progress report (+p), but leave out the happy message (-h). order matters, periodt π₯
the first batch of options are common to both ctangle and cweave:
+bβ print banner line on terminal+hβ print success message on completion+pβ print progress report messages+q/-qβ shortcut for-bhp; also--quiet(default)+v/-vβ shortcut for+bhp; also--verbose+cβ check temporary output for changes+sβ print usage statistics--helpβ display help message and exit--versionβ output version information and exit
there are two other options applicable to ctangle only:
+kβ keep separators in numeric literals in the output+uβ transliterate UTF-8 characters in C code
there are eight other options applicable to cweave only:
-eβ do not enclose C/C++ material in\PB{...}-fβ do not force a newline after every C/C++ statement in output-Fβ do not force a compound statement to start on a new line-iβ suppress indentation of parameter declarations-oβ suppress separation of declarations and statements-xβ omit indices, section names, table of contents+lX/-lXβ use macros for language X as ofXcwebmac.tex+tβ treattypenamein a template liketypedef
π ENVIRONMENT π
the environment variable CWEBINPUTS is used to search for the input files, or the system default if CWEBINPUTS is not set. see tex(1) for the details of the searching. to avoid conflicts with other programs that also use the CWEBINPUTS environment, you can be more specific and use CWEBINPUTS_cweb for special requirements in CWEB. yes, the name is long. she's specific and she knows what she wants π
if prepared for NLS support, ctangle and cweave use the environment variable TEXMFLOCALEDIR to configure the parent directory where the βGNU gettext utilitiesβ search for translation catalogs.
these variables are preconfigured in TeX Live's texmf.cnf. iykyk β¨
π FILES π
the location of the files mentioned below varies from system to system. use the kpsewhich utility to find their locations. (genuinely the move, bestie β don't go guessing at paths π)
cwebmac.tex: the default TeX macros\inputin the first line of thecweaveoutput file.cwebman.tex: the CWEB user manual, available in PDF from CTAN.
β SEE ALSO β
- The CWEB System of Structured Documentation: by Donald E. Knuth and Silvio Levy (hardcopy version of
cwebman.texand the source code listings ofcommon.w,ctangle.w, andcweave.w). - Literate Programming: by D. E. Knuth.
- Weaving a Program: by Wayne Sewell.
π AUTHORS π
Don Knuth wrote WEB for TeX and Pascal.
Silvio Levy designed and developed CWEB by adapting the WEB conventions to C and by recoding everything in CWEB. Knuth began using CWEB and made further refinements.
Many other helpers are acknowledged in the CWEB manual.
Contemporary development on https://github.com/ascherer/cweb.
and that's the whole page, bestie π«Ά go weave something iconic.
this little masterpiece is Web2c 2025, dated March 10, 2024 β thanks for reading, ily, mwah πβ¨
π¦ where this page comes from
- alpine 3.24: texmf-dist-binextra-doc 2026.0-r0 Β· LPPL-1.0 AND LPPL-1.1 AND LPPL-1.2 AND LPPL-1.3a AND LPPL-1.3c AND GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms