Loading ...
Sorry, an error occurred while loading the content.

Compilation Error

Expand Messages
  • pkasirajan
    Hi Guys, This is Kasirajan working in Impiger Technologied(P)Ltd.I am happy to join in this group.Let us share our knowledge through this big group. I am
    Message 1 of 2 , Jan 29, 2006
    • 0 Attachment
      Hi Guys,

      This is Kasirajan working in Impiger Technologied(P)Ltd.I am happy
      to join in this group.Let us share our knowledge through this big group.

      I am getting compilation error while running the below string_test.cpp
      in Linux.

      My gcc version is 3.2.2

      //string_test.cpp

      #include <iostream>
      #include <string>
      using namespace std;

      int main()
      {
      string name;
      name.append("Kasi");
      name.append(1,NULL);
      cout<<name;

      }


      ***************************************************

      Snapshot of the error

      [root@atmadax kasi]# gcc string_test.cpp -o string_test.exe
      string_test.cpp: In function `int main()':
      string_test.cpp:9: warning: passing NULL used for non-pointer argument
      2 of `
      std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT,
      _Traits, _Alloc>::append(_InputIterator, _InputIterator) [with
      _InputIterator = int, _CharT = char, _Traits = std::char_traits<char>,
      _Alloc = std::allocator<char>]'
      /usr/include/c++/3.2.2/bits/stl_iterator_base_types.h: At global scope:
      /usr/include/c++/3.2.2/bits/stl_iterator_base_types.h: In
      instantiation of `std::iterator_traits<int>':
      /usr/include/c++/3.2.2/bits/basic_string.h:688: instantiated from
      `std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT,
      _Traits,
      _Alloc>::replace(__gnu_cxx::__normal_iterator<_Alloc::pointer,
      std::basic_string<_CharT, _Traits, _Alloc> >,
      __gnu_cxx::__normal_iterator<_Alloc::pointer,
      std::basic_string<_CharT, _Traits, _Alloc> >, _InputIterator,
      _InputIterator) [with _InputIterator = int, _CharT = char, _Traits =
      std::char_traits<char>, _Alloc = std::allocator<char>]'
      /usr/include/c++/3.2.2/bits/basic_string.h:472: instantiated from
      `std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT,
      _Traits, _Alloc>::append(_InputIterator, _InputIterator) [with
      _InputIterator = int, _CharT = char, _Traits = std::char_traits<char>,
      _Alloc = std::allocator<char>]'
      string_test.cpp:9: instantiated from here
      /usr/include/c++/3.2.2/bits/stl_iterator_base_types.h:129: `int' is not a
      class, struct, or union type
      /usr/include/c++/3.2.2/bits/stl_iterator_base_types.h:130: `int' is not a
      class, struct, or union type
      /usr/include/c++/3.2.2/bits/stl_iterator_base_types.h:131: `int' is not a
      class, struct, or union type
      /usr/include/c++/3.2.2/bits/stl_iterator_base_types.h:132: `int' is not a
      class, struct, or union type
      /usr/include/c++/3.2.2/bits/stl_iterator_base_types.h:133: `int' is not a
      class, struct, or union type
      /usr/include/c++/3.2.2/bits/basic_string.h: In member function
      `std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT,
      _Traits,
      _Alloc>::replace(__gnu_cxx::__normal_iterator<_Alloc::pointer,
      std::basic_string<_CharT, _Traits, _Alloc> >,
      __gnu_cxx::__normal_iterator<_Alloc::pointer,
      std::basic_string<_CharT,
      _Traits, _Alloc> >, _InputIterator, _InputIterator) [with
      _InputIterator =
      int, _CharT = char, _Traits = std::char_traits<char>, _Alloc =
      std::allocator<char>]':
      /usr/include/c++/3.2.2/bits/basic_string.h:472: instantiated from
      `std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT,
      _Traits, _Alloc>::append(_InputIterator, _InputIterator) [with
      _InputIterator = int, _CharT = char, _Traits = std::char_traits<char>,
      _Alloc = std::allocator<char>]'
      string_test.cpp:9: instantiated from here
      /usr/include/c++/3.2.2/bits/basic_string.h:688: no type named `
      iterator_category' in `struct std::iterator_traits<int>'


      I would like to know how to solve this problem?
    • Michael Schwendt
      ... Run g++ (the C++ compiler) not gcc (the C compiler).
      Message 2 of 2 , Jan 30, 2006
      • 0 Attachment
        On 30/01/06, pkasirajan <rajankasi@...> wrote:
        > Hi Guys,
        >
        > This is Kasirajan working in Impiger Technologied(P)Ltd.I am happy
        > to join in this group.Let us share our knowledge through this big group.
        >
        > I am getting compilation error while running the below string_test.cpp
        > in Linux.
        >
        > My gcc version is 3.2.2
        >
        > //string_test.cpp
        >
        > #include <iostream>
        > #include <string>
        > using namespace std;
        >
        > int main()
        > {
        > string name;
        > name.append("Kasi");
        > name.append(1,NULL);
        > cout<<name;
        >
        > }
        >
        >
        > ***************************************************
        >
        > Snapshot of the error
        >
        > [root@atmadax kasi]# gcc string_test.cpp -o string_test.exe

        Run "g++" (the C++ compiler) not "gcc" (the C compiler).
      Your message has been successfully submitted and would be delivered to recipients shortly.