Hi, just started with TrueStudio. Trying to code a class with a template pattern results in error:
template <class TYPE, int SIZE>
class
{
...
};
Error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
Any help welcome...
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-28 11:42 AM
This discussion is locked. Please start a new topic to ask your question.
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-28 2:35 PM
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".
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-29 12:49 AM
A class without a template pattern makes no problem, so it must be C++. Only a template <whatever> has a problem.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-29 6:43 AM
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".
