从g ++ 3.3升级到g ++ 3.4时的编译问题 [英] Compilation problem when upgrading from g++ 3.3 to g++ 3.4
问题描述
下面的代码与GNU g ++ 3.3没有问题,
但是GNU g ++ 3.4有问题。
有什么建议吗?
------ foo.cpp ------
#include< vector>
using namespace std;
typedef char foo_t [3];
#define ELEM1" ab"
的#define elem2时" CD"
常量foo_t一个[] = {ELEM1,elem2时};
常量矢量< foo_t> v = vector< foo_t>(a,a + sizeof(a)/ sizeof(* a));
int main()
{
返回0;
}
---------------------
------使用GNU gcc编译3.3(Cygwin):BEGIN ------
$ g ++ --version
g ++(GCC)3.3.3(cygwin special)
[---省略---]
$ g ++ -W -Wall foo.cpp
//没有错误/警告
------使用GNU gcc编译3.3(Cygwin):结束--- -----
------用GNU gcc编写汇编3.4(DJGPP):开始------
$ gpp --version
gpp.exe(GCC)3.4.1
[---省略---]
$ gpp -W -Wall foo.cpp
c:/ djgpp / bin /../ lib / gcc / djgpp / 3.41 /../../../../ include / cxx / 3.41 / bits / stl_construct.h:在函数`void std :: _ Construct(_T1 *,const
_T2&)[with _T1 = char [3],_T2 = char [3]]'':
c:/ djgpp / bin /../ lib / gcc / djgpp / 3.41 /../../../../ include / cxx / 3.41 / bits / stl_uninit ialized.h:86:从`_ForwardIterator实例化
std :: __ uninitialized_copy_aux(_InputIterator,_InputIterator,_ForwardIterator,__ false_type)[with _InputIterator =
__gnu_cxx :: __ normal_iterator< const char (*)[3],std :: vector< char [3],std :: allocator< char [3]> > >,_ ForwardIterator = char(*)[3]]''
c:/ djgpp / bin /../ lib / gcc / djgpp / 3.41 /../../../。 ./include/cxx/3.41/bits/stl_uninitialized.h:112:从`_ForwardIterator实例化
std :: uninitialized_copy(_InputIterator,_InputIterator,_ForwardIterator)[with _InputIterator = __gnu_cxx :: __ normal_iterator< const
char(*)[3],std :: vector< char [3],std :: allocator< char [3]> > >,_ ForwardIterator = char(*)[3]]''
c:/ djgpp / bin /../ lib / gcc / djgpp / 3.41 /../../../。 ./include/cxx/3.41/bits/stl_vector.h:221:从`的std ::矢量<实例化; _TP,
_Alloc> ::矢量(常量的std ::矢量< _TP,_Alloc> &)[with _Tp = char [3],_ Alloc = std :: allocator< char [3]>]''
foo.cpp:9:从这里实例化
c:/ djgpp / bin /../ lib / gcc / djgpp / 3.41 /../../../../ include / cxx / 3.41 / bits / stl_construct.h:81:错误:ISO C ++禁止初始化
数组新
------使用GNU gcc 3.4编译(DJGPP):END --------
-
Alex Vinokur
电子邮件:alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
< a rel =nofollowhref =http://sourceforge.net/users/alexvntarget =_ blank> http://sourceforge.net/users/alexvn
Hi,
The code below has no problem with GNU g++ 3.3,
but it has a problem with GNU g++ 3.4.
Any suggestions?
------ foo.cpp ------
#include <vector>
using namespace std;
typedef char foo_t[3];
#define ELEM1 "ab"
#define ELEM2 "cd"
const foo_t a[] = {ELEM1, ELEM2};
const vector<foo_t> v = vector<foo_t>(a, a + sizeof (a)/sizeof (*a));
int main()
{
return 0;
}
---------------------
------ Compilation with GNU gcc 3.3 (Cygwin) : BEGIN ------
$ g++ --version
g++ (GCC) 3.3.3 (cygwin special)
[---omitted---]
$ g++ -W -Wall foo.cpp
// No errors/warnings
------ Compilation with GNU gcc 3.3 (Cygwin) : END --------
------ Compilation with GNU gcc 3.4 (DJGPP) : BEGIN ------
$ gpp --version
gpp.exe (GCC) 3.4.1
[---omitted---]
$ gpp -W -Wall foo.cpp
c:/djgpp/bin/../lib/gcc/djgpp/3.41/../../../../include/cxx/3.41/bits/stl_construct.h: In function `void std::_Construct(_T1*, const
_T2&) [with _T1 = char[3], _T2 = char[3]]'':
c:/djgpp/bin/../lib/gcc/djgpp/3.41/../../../../include/cxx/3.41/bits/stl_uninitialized.h:86: instantiated from `_ForwardIterator
std::__uninitialized_copy_aux(_InputIterator, _InputIterator, _ForwardIterator, __false_type) [with _InputIterator =
__gnu_cxx::__normal_iterator<const char (*)[3], std::vector<char[3], std::allocator<char[3]> > >, _ForwardIterator = char (*)[3]]''
c:/djgpp/bin/../lib/gcc/djgpp/3.41/../../../../include/cxx/3.41/bits/stl_uninitialized.h:112: instantiated from `_ForwardIterator
std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const
char (*)[3], std::vector<char[3], std::allocator<char[3]> > >, _ForwardIterator = char (*)[3]]''
c:/djgpp/bin/../lib/gcc/djgpp/3.41/../../../../include/cxx/3.41/bits/stl_vector.h:221: instantiated from `std::vector<_Tp,
_Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = char[3], _Alloc = std::allocator<char[3]>]''
foo.cpp:9: instantiated from here
c:/djgpp/bin/../lib/gcc/djgpp/3.41/../../../../include/cxx/3.41/bits/stl_construct.h:81: error: ISO C++ forbids initialization in
array new
------ Compilation with GNU gcc 3.4 (DJGPP) : END --------
--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn
推荐答案
g ++ --version
g ++(GCC)3.3.3(cygwin special)
[---省略--- ]
g++ --version
g++ (GCC) 3.3.3 (cygwin special)
[---omitted---]
g ++ -W -Wall foo.cpp
//没有错误/警告
------使用GNU gcc编译3.3(Cygwin):结束--------
------用GNU gcc编译3.4(DJGPP):开始------
g++ -W -Wall foo.cpp
// No errors/warnings
------ Compilation with GNU gcc 3.3 (Cygwin) : END --------
------ Compilation with GNU gcc 3.4 (DJGPP) : BEGIN ------
gpp --version
gpp.exe(GCC)3.4 .1
[---省略---]
gpp --version
gpp.exe (GCC) 3.4.1
[---omitted---]
这篇关于从g ++ 3.3升级到g ++ 3.4时的编译问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!