最近编译器的哪些更改导致这个半遗留 C++ 项目停止编译?

What recent compiler changes have caused this semi-legacy C++ project to stop compiling?

我最近尝试使用 GCC 4.9.3 构建 ReZound(轻量级 Linux 音频编辑器),但失败得很惨,并输出如下所示的混合错误。

为了确保不是我的 GCC 安装是罪魁祸首,我还测试了 LLVM 3.6.2 - 它发出了非常相似的错误 - 然后为了 100% 确定我在一个完整的平台上尝试了 GCC 4.8.4不同的机器,产生与 4.9.3 相同的错误。

ReZound 最后一次更新是在 2013 年,因此 合理地 是最近的;我希望这意味着对于没有 C++ 工作知识的人来说,必要的修改将是微不足道的:)

我有兴趣知道:

这是 GCC 4.9.4 从完整的库存中吐出的内容 ./configure 运行:

$ make
Making all in src
make[1]: Entering directory `/storage3/rezound-0.12.3beta/src'
Making all in misc
make[2]: Entering directory `/storage3/rezound-0.12.3beta/src/misc'
Making all in CNestedDataFile
make[3]: Entering directory `/storage3/rezound-0.12.3beta/src/misc/CNestedDataFile'
if /bin/sh ../../../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I../../../config -I../../../src/misc -I../../../src/misc/missing/generated -I../../../src/PoolFile    -g -Wall -Wno-unused-function -Wno-unused-variable -Wno-unused    -MT CNestedDataFile.lo -MD -MP -MF ".deps/CNestedDataFile.Tpo" \
  -c -o CNestedDataFile.lo `test -f 'CNestedDataFile.cpp' || echo './'`CNestedDataFile.cpp; \
then mv -f ".deps/CNestedDataFile.Tpo" ".deps/CNestedDataFile.Plo"; \
else rm -f ".deps/CNestedDataFile.Tpo"; exit 1; \
fi
 g++ -DHAVE_CONFIG_H -I. -I. -I../../../config -I../../../src/misc -I../../../src/misc/missing/generated -I../../../src/PoolFile -g -Wall -Wno-unused-function -Wno-unused-variable -Wno-unused -MT CNestedDataFile.lo -MD -MP -MF .deps/CNestedDataFile.Tpo -c CNestedDataFile.cpp -o CNestedDataFile.o
CNestedDataFile.cpp:21:2: warning: #warning parseFile doesnt need to set the filename, only the constructor and setFilename should do that [-Wcpp]
 #warning parseFile doesnt need to set the filename, only the constructor and setFilename should do that
  ^
CNestedDataFile.cpp:22:2: warning: #warning see about retaining the order that things were parsed in the file [-Wcpp]
 #warning see about retaining the order that things were parsed in the file
  ^
In file included from CNestedDataFile.h:31:0,
                 from CNestedDataFile.cpp:36:
../../../src/misc/CMutex.h:157:2: warning: access declarations are deprecated in favour of using-declarations; suggestion: add the 'using' keyword [-Wdeprecated]
  CMutexLocker::didLock;
  ^
In file included from CNestedDataFile.h:163:0,
                 from CNestedDataFile.cpp:36:
anytype.h:70:12: error: explicit template specialization cannot have a storage class
 template<> static const string string_to_anytype<string>(const string &str,string &ret)                         { return s2at::unescape_chars(s2at::remove_surrounding_quotes(str)); }
            ^
anytype.h:72:12: error: explicit template specialization cannot have a storage class
 template<> static const bool string_to_anytype<bool>(const string &str,bool &ret)                             { return s2at::remove_surrounding_quotes(str)=="true" ? ret=true : ret=false; }
            ^
anytype.h:74:12: error: explicit template specialization cannot have a storage class
 template<> static const char string_to_anytype<char>(const string &str,char &ret)                             { istringstream ss(s2at::remove_surrounding_quotes(str)); NO_LOCALE(ss) ret=0; ss >> ret; return ret; }
            ^
anytype.h:75:12: error: explicit template specialization cannot have a storage class
 template<> static const unsigned char string_to_anytype<unsigned char>(const string &str,unsigned char &ret)           { istringstream ss(s2at::remove_surrounding_quotes(str)); NO_LOCALE(ss) ret=0; ss >> ret; return ret; }
            ^
anytype.h:77:12: error: explicit template specialization cannot have a storage class
 template<> static const short string_to_anytype<short>(const string &str,short &ret)                           { istringstream ss(s2at::remove_surrounding_quotes(str)); NO_LOCALE(ss) ret=0; ss >> ret; return ret; }
            ^
anytype.h:78:12: error: explicit template specialization cannot have a storage class
 template<> static const unsigned short string_to_anytype<unsigned short>(const string &str,unsigned short &ret)         { istringstream ss(s2at::remove_surrounding_quotes(str)); NO_LOCALE(ss) ret=0; ss >> ret; return ret; }
            ^
anytype.h:80:12: error: explicit template specialization cannot have a storage class
 template<> static const int string_to_anytype<int>(const string &str,int &ret)                               { istringstream ss(s2at::remove_surrounding_quotes(str)); NO_LOCALE(ss) ret=0; ss >> ret; return ret; }
            ^
anytype.h:81:12: error: explicit template specialization cannot have a storage class
 template<> static const unsigned int string_to_anytype<unsigned int>(const string &str,unsigned int &ret)             { istringstream ss(s2at::remove_surrounding_quotes(str)); NO_LOCALE(ss) ret=0; ss >> ret; return ret; }
            ^
anytype.h:83:12: error: explicit template specialization cannot have a storage class
 template<> static const long string_to_anytype<long>(const string &str,long &ret)                             { istringstream ss(s2at::remove_surrounding_quotes(str)); NO_LOCALE(ss) ret=0; ss >> ret; return ret; }
            ^
anytype.h:84:12: error: explicit template specialization cannot have a storage class
 template<> static const unsigned long string_to_anytype<unsigned long>(const string &str,unsigned long &ret)           { istringstream ss(s2at::remove_surrounding_quotes(str)); NO_LOCALE(ss) ret=0; ss >> ret; return ret; }
            ^
anytype.h:86:12: error: explicit template specialization cannot have a storage class
 template<> static const long long string_to_anytype<long long>(const string &str,long long &ret)                   { istringstream ss(s2at::remove_surrounding_quotes(str)); NO_LOCALE(ss) ret=0; ss >> ret; return ret; }
            ^
anytype.h:87:12: error: explicit template specialization cannot have a storage class
 template<> static const unsigned long long string_to_anytype<unsigned long long>(const string &str,unsigned long long &ret) { istringstream ss(s2at::remove_surrounding_quotes(str)); NO_LOCALE(ss) ret=0; ss >> ret; return ret; }
            ^
anytype.h:89:12: error: explicit template specialization cannot have a storage class
 template<> static const float string_to_anytype<float>(const string &str,float &ret)                           { istringstream ss(s2at::remove_surrounding_quotes(str)); NO_LOCALE(ss) ret=0.0f; ss >> ret; return ret; }
            ^
anytype.h:90:12: error: explicit template specialization cannot have a storage class
 template<> static const double string_to_anytype<double>(const string &str,double &ret)                         { istringstream ss(s2at::remove_surrounding_quotes(str)); NO_LOCALE(ss) ret=0.0; ss >> ret; return ret; }
            ^
anytype.h:91:12: error: explicit template specialization cannot have a storage class
 template<> static const long double string_to_anytype<long double>(const string &str,long double &ret)               { istringstream ss(s2at::remove_surrounding_quotes(str)); NO_LOCALE(ss) ret=0.0; ss >> ret; return ret; }
            ^
In file included from CNestedDataFile.h:163:0,
                 from CNestedDataFile.cpp:36:
anytype.h:122:12: error: explicit template specialization cannot have a storage class
 template<> static const string anytype_to_string<string>(const string &any)             { return "\""+s2at::escape_chars(any)+"\""; }
            ^
In file included from CNestedDataFile.h:163:0,
                 from CNestedDataFile.cpp:36:
anytype.h:124:12: error: explicit template specialization cannot have a storage class
 template<> static const string anytype_to_string<bool>(const bool &any)               { return any ? "true" : "false"; }
            ^
anytype.h:126:12: error: explicit template specialization cannot have a storage class
 template<> static const string anytype_to_string<char>(const char &any)               { ostringstream ss; NO_LOCALE(ss) ss << any; return ss.str(); }
            ^
anytype.h:127:12: error: explicit template specialization cannot have a storage class
 template<> static const string anytype_to_string<unsigned char>(const unsigned char &any)      { ostringstream ss; NO_LOCALE(ss) ss << any; return ss.str(); }
            ^
anytype.h:129:12: error: explicit template specialization cannot have a storage class
 template<> static const string anytype_to_string<short>(const short &any)              { ostringstream ss; NO_LOCALE(ss) ss << any; return ss.str(); }
            ^
anytype.h:130:12: error: explicit template specialization cannot have a storage class
 template<> static const string anytype_to_string<unsigned short>(const unsigned short &any)     { ostringstream ss; NO_LOCALE(ss) ss << any; return ss.str(); }
            ^
anytype.h:132:12: error: explicit template specialization cannot have a storage class
 template<> static const string anytype_to_string<int>(const int &any)                { ostringstream ss; NO_LOCALE(ss) ss << any; return ss.str(); }
            ^
anytype.h:133:12: error: explicit template specialization cannot have a storage class
 template<> static const string anytype_to_string<unsigned int>(const unsigned int &any)       { ostringstream ss; NO_LOCALE(ss) ss << any; return ss.str(); }
            ^
anytype.h:135:12: error: explicit template specialization cannot have a storage class
 template<> static const string anytype_to_string<long>(const long &any)               { ostringstream ss; NO_LOCALE(ss) ss << any; return ss.str(); }
            ^
anytype.h:136:12: error: explicit template specialization cannot have a storage class
 template<> static const string anytype_to_string<unsigned long>(const unsigned long &any)      { ostringstream ss; NO_LOCALE(ss) ss << any; return ss.str(); }
            ^
anytype.h:138:12: error: explicit template specialization cannot have a storage class
 template<> static const string anytype_to_string<long long>(const long long &any)          { ostringstream ss; NO_LOCALE(ss) ss << any; return ss.str(); }
            ^
anytype.h:139:12: error: explicit template specialization cannot have a storage class
 template<> static const string anytype_to_string<unsigned long long>(const unsigned long long &any) { ostringstream ss; NO_LOCALE(ss) ss << any; return ss.str(); }
            ^
In file included from CNestedDataFile.h:163:0,
                 from CNestedDataFile.cpp:36:
anytype.h:144:12: error: explicit template specialization cannot have a storage class
 template<> static const string anytype_to_string<float>(const float &any)              { if(isnan(any)) return "0"; else { ostringstream ss; NO_LOCALE(ss) if(any>999999.0) {ss.setf(ios::scientific); ss.width(0); ss.precision(12); ss.fill(' '); } else {ss.setf(ios::fixed); ss.precision(6); ss.fill(' '); } ss << any; return istring(ss.str()).trim(); } }
            ^
anytype.h:145:12: error: explicit template specialization cannot have a storage class
 template<> static const string anytype_to_string<double>(const double &any)             { if(isnan(any)) return "0"; else { ostringstream ss; NO_LOCALE(ss) if(any>999999.0) {ss.setf(ios::scientific); ss.width(0); ss.precision(12); ss.fill(' '); } else {ss.setf(ios::fixed); ss.precision(6); ss.fill(' '); } ss << any; return istring(ss.str()).trim(); } }
            ^
anytype.h:146:12: error: explicit template specialization cannot have a storage class
 template<> static const string anytype_to_string<long double>(const long double &any)        { if(isnan(any)) return "0"; else { ostringstream ss; NO_LOCALE(ss) if(any>999999.0) {ss.setf(ios::scientific); ss.width(0); ss.precision(12); ss.fill(' '); } else {ss.setf(ios::fixed); ss.precision(6); ss.fill(' '); } ss << any; return istring(ss.str()).trim(); } }
            ^
make[3]: *** [CNestedDataFile.lo] Error 1
make[3]: Leaving directory `/storage3/rezound-0.12.3beta/src/misc/CNestedDataFile'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/storage3/rezound-0.12.3beta/src/misc'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/storage3/rezound-0.12.3beta/src'
make: *** [all-recursive] Error 1

如错误消息所述,static 无法应用于顶级模板。事实上,the most recent commit to the code 在 clang 和 gcc 4.3 及更高版本上明确删除了 static(通过 STATIC_TPL 宏)。

tl;dr:将您的代码更新到最新版本的 ReZound。您可能需要从 Subversion trunk.

获取代码