Title: # operator escapes backslashes outside string literals · Issue #714 · cppcheck-opensource/simplecpp · GitHub
Open Graph Title: # operator escapes backslashes outside string literals · Issue #714 · cppcheck-opensource/simplecpp
X Title: # operator escapes backslashes outside string literals · Issue #714 · cppcheck-opensource/simplecpp
Description: When the # operator turns a macro argument into a string, simplecpp puts a \ before every \, " and ' in the argument. The standard says a \ is inserted only before each " and \ that is part of a string literal or character constant (C11 ...
Open Graph Description: When the # operator turns a macro argument into a string, simplecpp puts a \ before every \, " and ' in the argument. The standard says a \ is inserted only before each " and \ that is part of a st...
X Description: When the # operator turns a macro argument into a string, simplecpp puts a \ before every \, " and ' in the argument. The standard says a \ is inserted only before each " and \ that i...
Opengraph URL: https://github.com/cppcheck-opensource/simplecpp/issues/714
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"# operator escapes backslashes outside string literals","articleBody":" When the `#` operator turns a macro argument into a string, simplecpp puts a `\\` before every `\\`, `\"` and `'` in the argument. The standard says a `\\` is inserted only before each `\"` and `\\` that is part of a string literal or\n character constant (C11 §6.10.3.2p2, C++ [cpp.stringize]). Other backslashes are copied unchanged, and `'` is never escaped.\n\n ### Example\n\n ```c\n #define str(x) #x\n str(\\n)\n str(: @\\n)\n str('\\4')\n ```\n\n | Input | Expected (gcc, clang) | Actual (simplecpp) |\n |---|---|---|\n | `str(\\n)` | `\"\\n\"` | `\"\\\\n\"` |\n | `str(: @\\n)` | `\": @\\n\"` | `\": @\\\\n\"` |\n | `str('\\4')` | `\"'\\\\4'\"` | `\"\\'\\\\4\\'\"` |\n\n `str(: @\\n)` is taken from the standard's own example (C11 §6.10.3.5, example 4). The clang testsuite case `c99-6_10_3_4_p6.c` fails for the same reason.\n","author":{"url":"https://github.com/danmar","@type":"Person","name":"danmar"},"datePublished":"2026-11-05T09:29:22Z","url":"https://github.com/cppcheck-opensource/simplecpp/issues/714"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:89c4496a-7dd8-638c-203e-de135bd67619 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C3EC:3FFB67:59761:82ECF:6AFC51D7 |
| html-safe-nonce | dd2f1a4166ad1ac05567d3c0658ace405084009da18fae5f9cb60201e67cda9f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDM0VDOjNGRkI2Nzo1OTc2MTo4MkVDRjo2QUZDNTFENyIsInZpc2l0b3JfaWQiOiI4NjQ3MTkyNjMyNDczOTY1MDE1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3aabc4dad2921c5e43a124848ffa71788842b5fbdc2021fadc08009942e2d8b9 |
| hovercard-subject-tag | issue:6220453046 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/cppcheck-opensource/simplecpp/714/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4ce23f68dea6a364d769dc578efbf9738a4387149a22356cc581968bc3b95c31/cppcheck-opensource/simplecpp/issues/714 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4ce23f68dea6a364d769dc578efbf9738a4387149a22356cc581968bc3b95c31/cppcheck-opensource/simplecpp/issues/714 |
| og:image:alt | When the # operator turns a macro argument into a string, simplecpp puts a \ before every \, " and ' in the argument. The standard says a \ is inserted only before each " and \ that is part of a st... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | danmar |
| hostname | github.com |
| expected-hostname | github.com |
| None | b63557e0027d8014589e873df28328da74a4356701bb1a9eab49dbf012ba8fa6 |
| turbo-cache-control | no-preview |
| go-import | github.com/cppcheck-opensource/simplecpp git https://github.com/cppcheck-opensource/simplecpp.git |
| octolytics-dimension-user_id | 278097703 |
| octolytics-dimension-user_login | cppcheck-opensource |
| octolytics-dimension-repository_id | 33434464 |
| octolytics-dimension-repository_nwo | cppcheck-opensource/simplecpp |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 33434464 |
| octolytics-dimension-repository_network_root_nwo | cppcheck-opensource/simplecpp |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0243355b0352c83733a042e0dfb3d75149b51261 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width