Compiling p_setup.cpp: [ERROR]
g++ -pipe -Wall -Wno-unused -fno-strict-aliasing -MMD -DHAVE_FILELENGTH -D__forceinline=inline -Izlib -IFLAC -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DNEED_STRUPR -Isrc/ -Isrc/g_doom/ -Isrc/g_heretic/ -Isrc/g_hexen/ -Isrc/g_raven/ -Isrc/g_shared/ -Isrc/g_strife/ -Isrc/oplsynth/ -Isrc/sound/ -Isrc/sdl/ -DUSEASM=1 -D_DEBUG -g3 -o debugobj/p_setup.o -c src/p_setup.cpp
================================================================================
In file included from src/p_setup.cpp:60:
src/p_setup.h: In member function `void MapData::Seek(int)':
src/p_setup.h:56: warning: comparison between signed and unsigned integer
expressions
src/p_setup.h: In member function `void MapData::Read(int, void*)':
src/p_setup.h:64: warning: comparison between signed and unsigned integer
expressions
src/p_setup.h: In member function `DWORD MapData::Size(int)':
src/p_setup.h:73: warning: comparison between signed and unsigned integer
expressions
src/p_setup.cpp: In function `int GetMapIndex(const char*, int, const char*)':
src/p_setup.cpp:212: error: type `GetMapIndex(const char*, int, const
char*)::<anonymous struct>' composed from a local class is not a valid
template-argument
src/p_setup.cpp:212: error: trying to instantiate `template<class T, unsigned
int N> char (& _ArraySizeHelper(T (&)[N]))[N]'
src/p_setup.cpp:212: error: no matching function for call to `_ArraySizeHelper(
GetMapIndex(const char*, int, const char*)::<anonymous struct>[13])'
src/p_setup.cpp: In function `void P_LoadSubsectors(MapData*)':
src/p_setup.cpp:961: warning: comparison between signed and unsigned integer
expressions
src/p_setup.cpp:971: warning: comparison between signed and unsigned integer
expressions
src/p_setup.cpp:975: warning: long unsigned int format, int arg (arg 3)
make: *** [debugobj/p_setup.o] Error 1
I'm sorry but you have to wait a little longer for an update. I'm extending the map loader so I can't commit another update until tomorrow. If you want to compile it right now just replace the countof() call with the actual size of the array or move the class definition out of the function.
g++ compiler-error.cpp
compiler-error.cpp: In function `int main()':
compiler-error.cpp:4: error: template-argument `main()::S' uses local type `
main()::S'
compiler-error.cpp:4: error: no matching function for call to `foo()'
Comeau C/C++ 4.3.3 (Aug 6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
Copyright 1988-2003 Comeau Computing. All rights reserved.
MODE:strict errors C++
"ComeauTest.c", line 4: error: a template argument may not reference a local type
foo<S> ();
^
1 error detected in the compilation of "ComeauTest.c".
Here's the best explanation I've found for why it's not allowed:
http://cpptips.hyperformix.com/cpptips/no_local_templ_arg wrote:Local classes have internal linkage, which means that only the local function may access the class. But the template function or template class that uses the local class may be instantiated at link time. But how is the linker to see the local class? It can't, and so local classes can't be used as template arguments of functions and classes.