为什么不用static_assert打印新行/其他控制序列?
问题描述:
int main(int argc, char **argv) {
static_assert(false, R"error(This is an error message. You need to
1. Pick up the phone.
2. Call GhostBusters.
3. Run and hide.
)error");
}
给为什么不用static_assert打印新行/其他控制序列?
error: static_assert failed "This is an error message. You need to\n\n1. Pick up the phone.\n2. Call GhostBusters.\n3. Run and hide.\n\n"
static_assert(false, err);
^ ~~~~~
1 error generated.
有谁知道这些都是 “转义” 的原因是什么?它是依赖于编译器/平台吗?标准的一部分?
答
的标准说无非:
所得诊断消息(4.1)应包括字串文本的文本,如果一个被提供,不同之处在于不是在基本源字符集中的字符( 5.3)不需要出现在诊断消息中。
换行符是基本源字符集的一部分,因此它们被要求“出现”。确切地说他们如何出现不是标准控件的问题。
嘎!好的,将在11分钟内接受x0谢谢! – sjm324