Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Raw strings for the C programming language

License

NotificationsYou must be signed in to change notification settings

RubyMetric/rawstr4c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.


Why do we still need it when we haveR"()"

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:

  1. R"()" is just an extension. Many projects that strictly adhere to-std=c* cannot use it
  2. Many C compilers may not implement this extension, limiting the choice of C compilers for projects
  3. LLVM only 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.


Install

rawstr4c on Raku Land

  1. InstallRakudo (bundled withzef)
  2. Then run:
$ zef install rawstr4c

Usage

$ rawstr4c --help

You need to write a Markdown file (defaultrawstr4c.md) to record raw strings and configurerawstr4c. See below for configuration syntax.


Convention

A configuration file should use this order:

  1. section title
  2. description of the variable
  3. configuration block (configblock)
  4. configuration block (configblock) comments
  5. code block (codeblock) (raw string)
  6. comments for the content of the code block (codeblock)

Configuration Syntax

- 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.


Configuration Items

Note: unless otherwise specified, the first item is the default value

  • output =

    • :terminal = output to terminal
    • :macro = output as a.h file, defined as macro
    • :global-variable = output a.h file and corresponding.c file, defined as global variable
    • :global-variable-only-header = output only as a.h file, defined as global variable
  • output-h-file =

    Custom generated header filename, default value israwstr4c.h

  • output-c-file =

    Custom generated C filename, default value israwstr4c.c

  • translate =

    • :escape = escape only
    • :oct = octal
    • :hex = hexadecimal
  • postfix =

    • :use-language = use the language of the codeblock
    • your 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 |true

    Ignore other configuration items and usename directly as the variable name

  • namespace =

    Serves as a prefix afterprefix and before variable namename, affecting nested sections

  • no-prefix =false |true

    Whether the variable name uses prefix

  • no-postfix =false |true

    Whether the variable name uses postfix


About

Raw strings for the C programming language

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp