Does C support raw string literals?

烂漫一生 提交于 2019-11-30 22:53:17

问题


C++11 added support for raw string literals, such as:

R"foo(A " weird \"
 string)foo"

Does C have such a thing? If so, in what version of the standard? C11? If not, does anyone know if it is being planed and if any compilers support it?


回答1:


Does C have such a thing? If so, in what version of the standard? C11?

C (C90, C99, C11) does not support this feature or any other similar feature.

If not, does anyone know if it is being planed

I have no idea, but usually there is a strong resistance of C committee to include new features in C.

and if any compilers support it?

I just tested it and it is apparently supported with recent gcc versions as a GNU extension (compile with -std=gnu99 or -std=gnu11).

For example:

printf(R"(hello\nworld\n)");

compiles and gives the expected behavior.



来源:https://stackoverflow.com/questions/24850244/does-c-support-raw-string-literals

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!