Find Related products on Amazon

Shop on Amazon

Make C string literals const?

Published on: 2025-05-12 06:02:12

Martin Uecker has started a new initiative to ensure a better const contract for C2y: change the type of string literals to a const -qualified base type, much as it is already the case in C++. Compilers support this since a very long time; some of them have this as default, some provide command line switches for that model. Nevertheless, this would be normative change and might be some burden for existing code. So, before doing this and writing papers, it would be good if we had an idea of the impact of such a change in existing code bases. I would be very grateful if we’d receive feedback from you along the lines of You have a project that already uses options such as gcc’s -Wwrite-strings (or even a compiler with such a default) to have all string literals const -qualified. (or even a compiler with such a default) to have all string literals -qualified. You have a project and you tested it with such options and introducing this change would be easy. (If so does this change expose ... Read full article.