Skip to main content
UJuer.1
Associate
July 28, 2020
Question

Hi, just started with TrueStudio. Trying to code a class with a template pattern results in error: template class { ... }; Error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token Any help welcome...

  • July 28, 2020
  • 3 replies
  • 1482 views

..

This topic has been closed for replies.

3 replies

TDK
Super User
July 28, 2020

Is your code in C or C++? Ensure the compiler sees it as C++.

"If you feel a post has answered your question, please click ""Accept as Solution""."
UJuer.1
UJuer.1Author
Associate
July 29, 2020

A class without a template pattern makes no problem, so it must be C++. Only a template <whatever> has a problem.

TDK
Super User
July 29, 2020

I'm aware you're trying to write C++ code. But if the file is named "something.c", the compiler will treat it as a C file.

If I use template within a C file, I get the exact error you've described:

...\printf.c:38:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
 template <class T>
 ^
mingw32-make.exe[3]: ***

"If you feel a post has answered your question, please click ""Accept as Solution""."