【问题标题】:Clion unable to parse templateClion 无法解析模板
【发布时间】:2019-05-31 13:41:47
【问题描述】:

我在 Clion 中创建了以下文件模板,但是当我尝试创建文件时,它显示“无法解析模板”。有什么问题?

#include <bits/stdc++.h>

using namespace std;

#define endl "\n"

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    return 0;
}

【问题讨论】:

  • 两件事:首先是please don't include &lt;bits/stdc++.h&gt;。其次,不要使用宏重新定义常用符号。最后,如果您想编写换行符,请使用显式换行符,如 '\n'
  • Clion 文件模板是使用 Velocity 模板语言编写的(请参阅 jetbrains.com/help/clion/using-file-and-code-templates.html)。我对此一无所知,但查看快速参考(请参阅此处velocity.apache.org/engine/2.0/vtl-reference.html)我猜#include 是问题所在。你需要找到一种方法来解释它的字面意思。
  • 除了上面的评论,似乎您需要在文件的开头和结尾放置#[[]]#
  • @Someprogrammerdude 这不是生产代码,我只是在测试系统中实现算法
  • 不管怎样,当你重新定义endl时你的程序有UB。

标签: c++ clion file-templates


【解决方案1】:

模板格式要求文件的开头和结尾分别有#[[ 和#]]。 更多信息jetbrains.com/help/clion/using-file-and-code-templates.html

谢谢@约翰

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-11
    • 1970-01-01
    • 1970-01-01
    • 2020-05-23
    • 2019-02-20
    • 1970-01-01
    相关资源
    最近更新 更多