[cfe-dev] Clang: template functions
Sebastian Redl
sebastian.redl at getdesigned.at
Fri Nov 5 04:15:39 PDT 2010
On 05.11.2010 11:53, Stefano S wrote:
> Hi,
>
> For the first time I built llvm + clang on ubuntu box for giving it a
> try.
>
> I have this simple template function in a header file
>
> template <typename T, typename U>
> inline void SetMin(T &aVar,U aValue);
>
> but clang++ returns
>
> ../src/myfile.h:13:1: error: unknown type name 'template'
> template <typename T, typename U>
> ^
> ../src/myfile.h:13:10: error: expected identifier or '('
> template <typename T, typename U>
>
> I tried to use also -std=gnu89 because I've read gcc (which compiles
> my code) uses that standard by default, but with no success.
>
Sounds like you're trying to compile C++ code as C. Just because you
invoke Clang as clang++ doesn't mean it runs in C++ mode, it only means
it will link against the C++ runtime libraries. To actually compile in
C++ mode, the file must have a C++ extension (.cxx, .cpp or .cc), or you
have to override the language detection with the -x option.
Sebastian
More information about the cfe-dev
mailing list