- Notifications
You must be signed in to change notification settings - Fork0
Raw strings for the C programming language
License
RubyMetric/rawstr4c
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
rawstr4c - Raw strings for the C programming language
The key innovation ofrawstr4c is its use of a Markdown file to explicitly define raw strings inside code blocks — allowing you to fully leverage your editor’s syntax highlighting feature to beautifully render them!
Note
rawstr4c was originally developed forchsrc, and is now maintained as a subproject of it.chsrc benefits greatly fromrawstr4c.
Why implemented inRaku?
BecauseRaku is theRAw strings Kungfu Utility!
rawstr4c has no module dependencies by design — just installRakudo via your package manager and you're ready to go. Lightweight, hassle-free, anda perfect excuse to explore Raku, the language you can have fun with.
Until now (2025-07), the C language does not have raw strings in its current ISO standard, butbothGCC andClang have already implemented the extensionR"()". In fact, it is enabled by default inGCC.
However, there are several reasons why we still needrawstr4c:
R"()"is just an extension. Many projects that strictly adhere to-std=c*cannot use it- Many C compilers may not implement this extension, limiting the choice of C compilers for projects
LLVMonly supports this extension after July 2024; versions prior to that do not support it
Even if direct raw strings support is added in future C standards likeC3x orC4x,rawstr4c still remains meaningful, because when raw strings are written directly in source code files, they cannot be properly highlighted according to the content.
Inchsrc, we use both the nativeR"()" form and alsorawstr4c to get the maximum flexibility and maintainability.
- InstallRakudo (bundled with
zef) - Then run:
$ zef install rawstr4c
$ rawstr4c --help
You need to write a Markdown file (defaultrawstr4c.md) to record raw strings and configurerawstr4c. See below for configuration syntax.
A configuration file should use this order:
- section title
- description of the variable
- configuration block (configblock)
- configuration block (configblock) comments
- code block (codeblock) (raw string)
- comments for the content of the code block (codeblock)
- config-item1 =`:mode`- config-item2 =`true|false|yes|no`- config-item3 =`string value`
Configuration items always start with-, followed by the configuration item name and an=. The right-hand value must be wrapped with``.
Note: if the value is not arbitrarily given by the user, it should be set as a mode type, using: as a prefix.
Note: unless otherwise specified, the first item is the default value
output =
:terminal= output to terminal:macro= output as a.hfile, defined as macro:global-variable= output a.hfile and corresponding.cfile, defined as global variable:global-variable-only-header= output only as a.hfile, defined as global variable
output-h-file =
Custom generated header filename, default value is
rawstr4c.houtput-c-file =
Custom generated C filename, default value is
rawstr4c.ctranslate =
:escape= escape only:oct= octal:hex= hexadecimal
postfix =
:use-language= use the language of the codeblockyour string= use a custom string as suffix
name =
Generated variable name, includes prefix and suffix by default. If this configuration item is not given, the section title will be used
name-literally =
false|trueIgnore other configuration items and use
namedirectly as the variable namenamespace =
Serves as a prefix after
prefixand before variable namename, affecting nested sectionsno-prefix =
false|trueWhether the variable name uses prefix
no-postfix =
false|trueWhether the variable name uses postfix
About
Raw strings for the C programming language
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.