1

I created the following file template in Clion, but when I tried to create a file it said "Unable to parse template". What could be wrong?

#include <bits/stdc++.h>

using namespace std;

#define endl "\n"

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

    return 0;
}
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
Joseph Kirtman
  • 349
  • 2
  • 10
  • 1
    Two things: First of all [please don't include ``](https://stackoverflow.com/questions/31816095/why-should-i-not-include-bits-stdc-h). Secondly don't redefine common symbols using macros. Lastly if you want to write a newline, use explicit newline as in `'\n'`. – Some programmer dude May 31 '19 at 13:54
  • Clion file templates are written using the Velocity Template Language (see https://www.jetbrains.com/help/clion/using-file-and-code-templates.html). I know nothing about this, but looking at the quick reference (see here http://velocity.apache.org/engine/2.0/vtl-reference.html) I would guess that the `#include` is the problem. You need to find a way for that to be interpretted literally. – john May 31 '19 at 14:08
  • Further to the comment above, its seems that you need to put `#[[` and `]]#` at the beginning and end of your file. – john May 31 '19 at 14:10
  • @Someprogrammerdude It's not a production code, I just implement algorithms in a tester system – Joseph Kirtman May 31 '19 at 14:26
  • Regardless, your program has UB when you redefined `endl`. – Lightness Races in Orbit May 31 '19 at 14:31
  • Habits tends to stick, bad as well as good. So better start with good habits from the beginning. In which case you probably should read [Why is “using namespace std;” considered bad practice?](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice) as well. – Some programmer dude May 31 '19 at 19:08

1 Answers1

1

Template format requires #[[ and #]] at beginning and end of the file respectively. More information jetbrains.com/help/clion/using-file-and-code-templates.html

Thanks @john

Joseph Kirtman
  • 349
  • 2
  • 10