Compile errors in stl header files

This is a discussion on Compile errors in stl header files within the C++ Programming forums, part of the General Programming Boards category; Hello, Writing my program, went to compile. Fixed all my own compile errors, then found another batch complaining about the ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    25

    Compile errors in stl header files

    Hello,
    Writing my program, went to compile. Fixed all my own compile errors, then found another batch complaining about the stl libraries.
    Code:
    istringstream sin;
    sin.str(curword);
    GLfloat pt[3];
    sin.ignore(100, '(');
    sin >>  pt[0] >> pt[1] >> pt[2] ;
    sin.ignore(2, '}');
    cout << "point: " << pt[0] << "  " << pt[1] << "  " << pt[2] << endl;
    points.push_back(pt);
    Points is a member variable, of type std::vector <GLfloat[3]> points;

    The compile errors all complain about points.push_back(pt); I suspect it is a problem with the use of GLfloats with std::vectors, but not entirely sure, and not sure how to fix it if this is the problem.

    I'm building in Dev-C++, and the compile log is as follows.
    Code:
    Compiler: Default GCC compiler
    Building Makefile: "C:\arenagame\code\an8loader\Makefile.win"
    Executing  make...
    mingw32-make.exe -f "C:\arenagame\code\an8loader\Makefile.win" all 
    gcc.exe -c model.cpp -o "Default Profile/model.o" -I"include"   
    
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_construct.h: In function `void std::_Construct(_T1*, const _T2&) [with _T1 = GLfloat[3], _T2 = GLfloat[3]]':
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_vector.h:560:   instantiated from `void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = GLfloat[3], _Alloc = std::allocator<GLfloat[3]>]'
    model.cpp:45:   instantiated from here
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_construct.h:81: error: ISO C++ forbids initialization in array new
    
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/vector.tcc: In member function `void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx::__normal_iterator<typename _Alloc::pointer, std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = GLfloat[3], _Alloc = std::allocator<GLfloat[3]>]':
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_vector.h:564:   instantiated from `void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = GLfloat[3], _Alloc = std::allocator<GLfloat[3]>]'
    model.cpp:45:   instantiated from here
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/vector.tcc:234: error: invalid initializer
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_vector.h:564:   instantiated from `void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = GLfloat[3], _Alloc = std::allocator<GLfloat[3]>]'
    model.cpp:45:   instantiated from here
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/vector.tcc:238: error: ISO C++ forbids assignment of arrays
    
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_algobase.h: In function `_BidirectionalIterator std::__copy_backward(_RandomAccessIterator, _RandomAccessIterator, _BidirectionalIterator, std::random_access_iterator_tag) [with _RandomAccessIterator = GLfloat (*)[3], _BidirectionalIterator = GLfloat (*)[3]]':
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_algobase.h:396:   instantiated from `static _BidirectionalIterator2 std::__copy_backward_dispatch<_BidirectionalIterator1, _BidirectionalIterator2, _BoolType>::copy(_BidirectionalIterator1, _BidirectionalIterator1, _BidirectionalIterator2) [with _BidirectionalIterator1 = GLfloat (*)[3], _BidirectionalIterator2 = GLfloat (*)[3], _BoolType = __false_type]'
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_algobase.h:429:   instantiated from `_BI2 std::__copy_backward_aux(_BI1, _BI1, _BI2) [with _BI1 = GLfloat (*)[3], _BI2 = GLfloat (*)[3]]'
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_algobase.h:439:   instantiated from `_BI2 std::__copy_backward_output_normal_iterator(_BI1, _BI1, _BI2, __true_type) [with _BI1 = GLfloat (*)[3], _BI2 = __gnu_cxx::__normal_iterator<GLfloat (*)[3], std::vector<GLfloat[3], std::allocator<GLfloat[3]> > >]'
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_algobase.h:453:   instantiated from `_BI2 std::__copy_backward_input_normal_iterator(_BI1, _BI1, _BI2, __true_type) [with _BI1 = __gnu_cxx::__normal_iterator<GLfloat (*)[3], std::vector<GLfloat[3], std::allocator<GLfloat[3]> > >, _BI2 = __gnu_cxx::__normal_iterator<GLfloat (*)[3], std::vector<GLfloat[3], std::allocator<GLfloat[3]> > >]'
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_algobase.h:498:   instantiated from `_BI2 std::copy_backward(_BI1, _BI1, _BI2) [with _BI1 = __gnu_cxx::__normal_iterator<GLfloat (*)[3], std::vector<GLfloat[3], std::allocator<GLfloat[3]> > >, _BI2 = __gnu_cxx::__normal_iterator<GLfloat (*)[3], std::vector<GLfloat[3], std::allocator<GLfloat[3]> > >]'
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/vector.tcc:235:   instantiated from `void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx::__normal_iterator<typename _Alloc::pointer, std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = GLfloat[3], _Alloc = std::allocator<GLfloat[3]>]'
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_vector.h:564:   instantiated from `void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = GLfloat[3], _Alloc = std::allocator<GLfloat[3]>]'
    model.cpp:45:   instantiated from here
    C:/Program Files/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_algobase.h:380: error: ISO C++ forbids assignment of arrays
    
    mingw32-make.exe: *** [Default Profile/model.o] Error 1
    
    Execution terminated
    Thanks for reading. What can I do? I assume there aren't this many bugs in the STL header files :S
    Last edited by Swordsalot; 07-19-2008 at 10:27 PM.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,325
    >> std::vector <GLfloat[3]> points;
    It seems you can't have a vector of arrays. Perhaps place the GLfloat[3] in a simple struct and hold that in the vector.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    One of the problems with templates is that the compile errors for your code may appear in code you didn't write.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Header Files
    By devarishi in forum C Programming
    Replies: 8
    Last Post: 12-10-2008, 03:53 PM
  2. Errors with header files in OpenGL using VisualC++
    By wile_spice in forum Game Programming
    Replies: 3
    Last Post: 06-22-2006, 08:56 AM
  3. Linker errors - Multiple Source files
    By nkhambal in forum C Programming
    Replies: 3
    Last Post: 04-24-2005, 02:41 AM
  4. Header files
    By Jez_Master in forum C++ Programming
    Replies: 2
    Last Post: 04-08-2002, 07:56 AM
  5. Compile Errors Due to STL & Iterator
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 12-02-2001, 09:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21