Search code examples
c++eclipsetemplatestizen

C++ unknown type name template - Eclipse


I'm trying to import some sources intro my project. And I came across this error when trying to compile.

6:1: error: unknown type name 'template'

The header that gets the error looks something like this.

template <typename T> T MyMin(T a, T b)
  {  return a < b ? a : b; }

template <class T> inline T MyMax(T a, T b)
  {  return a > b ? a : b; }

template <class T> inline int MyCompare(T a, T b)
  {  return a < b ? -1 : (a == b ? 0 : 1); }

inline int BoolToInt(bool value)
  { return (value ? 1: 0); }

inline bool IntToBool(int value)
  { return (value != 0); }
  • I'm using the Tizen SDK 2.0 which is based on Eclipse Indigo.
  • I have Cygwin installed and the default C++ compiler used is clang++

If you need more details just let me know.

Do you have any ideea what the problem might be?


Solution

  • I found out that my MyLibrary.h was compiled using the gcc because it was called inside a .c source file.

    This was due to a multitude of includes which all led to the same file.

    Because the gcc was used, the keyword template wasn't recognized.

    Fixed it by making the g++ compile the source file where MyLibrary.h was included.