Errors in "stl_algobase.h"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • v859
    New Member
    • May 2010
    • 9

    Errors in "stl_algobase.h"

    I fixed all of the errors in the code that I wrote, however, I am now getting errors in this document called "stl_algobase.h " which I don't even know what it is.

    they follow the form of

    instantiated from `_OutputIterato r std::_copy_aux2 (_InputIterator ,_InputIterator ,_OutputIterato r,_false_type)[with_InputIteat or=char[*][10],_OutputIterato r=int]'

    I think it is trying to tell me that I am trying to output an array of characters like integers, but I don't know how to fix it.

    Here is the code that I think is causing the problem:

    Code:
    void print(char temporaryArray[][10], int MAX_SIZE)
    {
       for(int local = 0; local < MAX_SIZE; local++)
       {
         for( int loop = 0; loop <=9; loop++)
         {
            cout<< temporaryArray[local][loop];
         }
            cout<<endl;
       }
    }
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Normally there are several other errors round an error like this all relating to the same problem. When posting errors you should post them all and you should post them in there entirety because trying to diagnose problems with half the information is very hard.

    The error you have printed is not the actually error but just a pointer to the code that cause the code with the error in it to be instantiated.

    Comment

    • v859
      New Member
      • May 2010
      • 9

      #3
      This is the entire error screen:

      C:\Dev-Cpp\include\c++ \3.4.2\bits\stl _algobase.h In function `_OutputIterato r std::__copy(_Ra ndomAccessItera tor, _RandomAccessIt erator, _OutputIterator , std::random_acc ess_iterator_ta g) [with _RandomAccessIt erator = char (*)[10], _OutputIterator = int]':

      266 C:\Dev-Cpp\include\c++ \3.4.2\bits\stl _algobase.h instantiated from `_OutputIterato r std::__copy_aux 2(_InputIterato r, _InputIterator, _OutputIterator , __false_type) [with _InputIterator = char (*)[10], _OutputIterator = int]'

      308 C:\Dev-Cpp\include\c++ \3.4.2\bits\stl _algobase.h instantiated from `_OutputIterato r std::__copy_ni2 (_InputIterator , _InputIterator, _OutputIterator , __false_type) [with _InputIterator = char (*)[10], _OutputIterator = int]'

      327 C:\Dev-Cpp\include\c++ \3.4.2\bits\stl _algobase.h instantiated from `_OutputIterato r std::__copy_ni1 (_InputIterator , _InputIterator, _OutputIterator , __false_type) [with _InputIterator = char (*)[10], _OutputIterator = int]'

      358 C:\Dev-Cpp\include\c++ \3.4.2\bits\stl _algobase.h instantiated from `_OutputIterato r std::copy(_Inpu tIterator, _InputIterator, _OutputIterator ) [with _InputIterator = char (*)[10], _OutputIterator = int]'

      190 C:\Documents and Settings\myfirs t.lastname\My Documents\Untit led1.cpp instantiated from here

      247 C:\Dev-Cpp\include\c++ \3.4.2\bits\stl _algobase.h invalid type argument of `unary *'

      This is the line of code the error is coming from
      Code:
      copy(tempArray, inputArray, MAX_SIZE);
      And this is the function
      Code:
      void copy(char temporaryArray1[][10], char previousarray[][10], int MAX_SIZE)
      {
         for(int i = 0; i < MAX_SIZE; i++)
         {
             for(int j =0; j <= 9; j++)
             {
                temporaryArray1[i][j] = previousarray[i][j];
             }
          }
      }

      Comment

      • v859
        New Member
        • May 2010
        • 9

        #4
        I actually solved that problem.

        I had as my prototype:
        Code:
        void copy(char[][10], int);
        but two character arrays as inputs.

        However I am now getting the following errors

        221 C:\Documents and Settings\vincen t.cannavale\My Documents\Untit led1.cpp new declaration `char copy(char (*)[10], char (*)[10], int)'

        11 C:\Documents and Settings\vincen t.cannavale\My Documents\Untit led1.cpp ambiguates old declaration `void copy(char (*)[10], char (*)[10], int)'

        Comment

        • Banfa
          Recognized Expert Expert
          • Feb 2006
          • 9067

          #5
          So does line 190 of Untitled1.cpp fall within the function you have posted?

          I have to say your posted code compiles fine for me.

          Also stl_algobase.h is part fo the STL Algorithms implementation in gcc and this error speaks of a problem in either a STL algorithm or an STL container none of which appear in the posted code snippet.

          Comment

          • v859
            New Member
            • May 2010
            • 9

            #6
            Thanks for everyone's help.

            I fixed all of the compile time errors, however, the program now crashes in runtime, and I have no idea why.

            Comment

            • Banfa
              Recognized Expert Expert
              • Feb 2006
              • 9067

              #7
              Run it in the debugger you might get extra information.

              Or if the program is short just step through it in the debugger until it crashes.

              Or narrow down where it crashes slowly with repetitive runs of the debugger, rather than step use next to execute a whole function, work out which function call in main causes the crash, the run the debugger again and step into that function and then use next again to work out which line causes the crash and continue until you narrow it down to a few lines.

              Examine code (either right away for after narrowing down the search area) for possible causes of the crash like writing outside the bounds of an array.

              Comment

              • v859
                New Member
                • May 2010
                • 9

                #8
                How do you use the debugger, every time I try, it doesn't work right.

                Comment

                • Banfa
                  Recognized Expert Expert
                  • Feb 2006
                  • 9067

                  #9
                  You will have to describe your problem a little better than "it doesn't work right".

                  What do you do?
                  What happens/what do you see?
                  What is your platform?
                  Are you using an IDE?

                  Comment

                  • weaknessforcats
                    Recognized Expert Expert
                    • Mar 2007
                    • 9214

                    #10
                    The problem is that the STL has an algorithm named copy. Because you have coded using namespace std, that template is being used instead of your function.

                    The easy fix is to rename your funciton to MyCopy and all these errors will go away.

                    BTW: There is also a swap in STL so don't name your function swap.

                    The better fix is to put your function in your own namesopace:

                    Code:
                    namespace MyStuff
                    {
                         void copy(char temporaryArray1[][10], char previousarray[][10], int MAX_SIZE) 
                    { 
                       for(int i = 0; i < MAX_SIZE; i++) 
                       { 
                           for(int j =0; j <= 9; j++) 
                           { 
                              temporaryArray1[i][j] = previousarray[i][j]; 
                           } 
                        } 
                    } 
                      
                    }
                    
                    
                    } // end of namespace
                    This should be in its own implementation file.

                    Then create a header file:

                    Code:
                    namespace MyStuff
                    {
                         void copy(char temporaryArray1[][10], char previousarray[][10], int MAX_SIZE); 
                    
                    } // end of namespace
                    #include this header in the file with main() and make your call:

                    Code:
                    MyStuff::copy(tempArray, inputArray, MAX_SIZE);

                    Comment

                    Working...