情境:
我在两台不同的机器上构建软件
其中一台机器具有完全兼容的C ++ 11版本g++
另一个没有。
计算机1(Linux):
$ g++ --version
g++ (Ubuntu 5.1.0-0ubuntu11~14.04.1) 5.1.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
计算机2(带有Cygwin的Windows):
$ g++ --version
g++ (GCC) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
我在这两台机器上构建的C ++软件一直支持C ++ 98。
但是,如果可用的话,将使用C ++的新功能 (有问题的软件,C++ Catch用于单元测试)。
问题:
我有一个通用的makefile来构建这个软件。在Cygwin
上,它成功构建了软件。在Linux
上,使用较新的编译器,它无法构建,因为我认为它检测到编译器的版本并尝试使用更现代的C ++功能。
这是用于扫视目的的错误转储。大多只是nullptr_t
相关。也许与模板演绎的新规则有关(不完全确定):
catch.hpp:833:17: error: ‘nullptr_t’ in namespace ‘std’ does not name a type
inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; }
^
catch.hpp:954:58: error: ‘template<Catch::Internal::Operator Op, class T> bool Catch::Internal::compare’ conflicts with a previous declaration
template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) {
^
catch.hpp:948:44: note: previous declaration ‘namespace Catch::Internal { }::compare’
template<Operator Op, typename T> bool compare( T* lhs, int rhs ) {
^
catch.hpp:954:53: error: ‘nullptr_t’ is not a member of ‘std’
template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) {
^
catch.hpp:954:70: error: expected primary-expression before ‘*’ token
template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) {
^
catch.hpp:954:72: error: ‘rhs’ was not declared in this scope
template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) {
^
catch.hpp:954:76: error: expression list treated as compound expression in initializer [-fpermissive]
template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) {
^
catch.hpp:954:44: warning: variable templates only available with -std=c++14 or -std=gnu++14
template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) {
^
catch.hpp:954:78: error: expected ‘;’ before ‘{’ token
template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) {
^
catch.hpp:957:66: error: ‘std::nullptr_t’ has not been declared
template<Operator Op, typename T> bool compare( T* lhs, std::nullptr_t ) {
^
catch.hpp:957:44: error: redefinition of ‘template<Catch::Internal::Operator Op, class T> bool Catch::Internal::compare(T*, int)’
template<Operator Op, typename T> bool compare( T* lhs, std::nullptr_t ) {
^
catch.hpp:948:44: note: ‘template<Catch::Internal::Operator Op, class T> bool Catch::Internal::compare(T*, int)’ previously declared here
template<Operator Op, typename T> bool compare( T* lhs, int rhs ) {
^
In file included from main.cpp:2:0:
catch.hpp:1088:38: error: ‘std::string Catch::toString’ redeclared as different kind of symbol
std::string toString( std::nullptr_t );
^
catch.hpp:1085:13: note: previous declaration ‘std::string Catch::toString(unsigned char)’
std::string toString( unsigned char value );
^
catch.hpp:1088:23: error: ‘nullptr_t’ is not a member of ‘std’
std::string toString( std::nullptr_t );
^
In file included from main.cpp:2:0:
catch.hpp:7336:38: error: ‘std::string Catch::toString’ redeclared as different kind of symbol
std::string toString( std::nullptr_t ) {
^
In file included from main.cpp:2:0:
catch.hpp:1232:13: note: previous declaration ‘template<class T, class Allocator> std::string Catch::toString(const std::vector<_Tp, _Alloc>&)’
std::string toString( std::vector<T,Allocator> const& v ) {
^
In file included from main.cpp:2:0:
catch.hpp:7336:23: error: ‘nullptr_t’ is not a member of ‘std’
std::string toString( std::nullptr_t ) {
通过确保使用Linux
标志编译g++
,可以在--std=c++11
计算机上轻松修复此问题。但是,我不希望两台机器上有两个单独的makefile。我无法在两个版本中添加--std=c++11
标记,因为版本4.9
尚未拥有该标记。
问题:
如何在不同版本的g++
上使用相同的命令启用交叉编译?代码根据g++
的版本构建不同 - 在这种情况下,有时需要传递std
标志。
其他
我尝试为两个版本提供g++
标记--std=c++98
,但它仍然在Linux
版本上失败。这里的目标是在两台机器上使用相同类型的命令。
答案 0 :(得分:0)
在Windows平台上,我建议使用Stephan Lavavej的Nuwen Distro。唯一的障碍是您无法使用boost::thread
设施,但Root->Table 1
Each root can have 'n' number of parents -Table 2
Each parent can have 'n' number of children- Table 3
There is an image associated with each children saved in Table 4
which has image stored for each children in varbinary format.
提供了几乎无缝的替代方案。
答案 1 :(得分:0)