2014-08-28 130 views
-3

我下面的一個C++教程,並試圖編譯第二個練習,我得到這個真棒結果時:無法編譯簡單的C++程序

enter image description here

它的代碼一個永無止境的滾動而沒有什麼事情發生。 我使用的編譯代碼是:

cpp Small.cpp 

...和文件的代碼是:

#include <iostream> 

int main(){ 
    std::cout << "Hello!" << std::endl << 2+2; 
    return 0; 
} 

我不知道如何甚至開始尋找這個錯誤。

編譯器是最新的MinGW for Windows。

編輯:我可以恢復的內容:

{ 
     template<typename _Tp> 
     static _Tp* 
     __copy_move_b(const _Tp* __first, const _Tp* __last, _Tp* __result) 
     { 
    const ptrdiff_t _Num = __last - __first; 
    if (_Num) 
    __builtin_memmove(__result - _Num, __first, sizeof(_Tp) * _Num); 
    return __result - _Num; 
} 
    }; 

    template<bool _IsMove, typename _BI1, typename _BI2> 
    inline _BI2 
    __copy_move_backward_a(_BI1 __first, _BI1 __last, _BI2 __result) 
    { 
     typedef typename iterator_traits<_BI1>::value_type _ValueType1; 
     typedef typename iterator_traits<_BI2>::value_type _ValueType2; 
     typedef typename iterator_traits<_BI1>::iterator_category _Category; 
     const bool __simple = (__is_trivial(_ValueType1) 
         && __is_pointer<_BI1>::__value 
         && __is_pointer<_BI2>::__value 
     && __are_same<_ValueType1, _ValueType2>::__value); 

     return std::__copy_move_backward<_IsMove, __simple, 
           _Category>::__copy_move_b(__first, 
     __last, 
     __result); 
    } 

    template<bool _IsMove, typename _BI1, typename _BI2> 
    inline _BI2 
    __copy_move_backward_a2(_BI1 __first, _BI1 __last, _BI2 __result) 
    { 
     return _BI2(std::__copy_move_backward_a<_IsMove> 
    (std::__niter_base(__first), std::__niter_base(__last), 
    std::__niter_base(__result))); 
    } 
# 617 "c:\\tdm-gcc-32\\lib\\gcc\\mingw32\\4.8.1\\include\\c++\\bits\\stl_algoba 
e.h" 3 
    template<typename _BI1, typename _BI2> 
    inline _BI2 
    copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) 
    { 






     ; 

     return (std::__copy_move_backward_a2<__is_move_iterator<_BI1>::__value> 
     (std::__miter_base(__first), std::__miter_base(__last), 
     __result)); 
    } 
# 675 "c:\\tdm-gcc-32\\lib\\gcc\\mingw32\\4.8.1\\include\\c++\\bits\\stl_algoba 
e.h" 3 
    template<typename _ForwardIterator, typename _Tp> 
    inline typename 
    __gnu_cxx::__enable_if<!__is_scalar<_Tp>::__value, void>::__type 
    __fill_a(_ForwardIterator __first, _ForwardIterator __last, 
     const _Tp& __value) 
    { 
     for (; __first != __last; ++__first) 
*__first = __value; 
    } 

    template<typename _ForwardIterator, typename _Tp> 
    inline typename 
    __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type 
    __fill_a(_ForwardIterator __first, _ForwardIterator __last, 
     const _Tp& __value) 
    { 
     const _Tp __tmp = __value; 
     for (; __first != __last; ++__first) 
*__first = __tmp; 
    } 


    template<typename _Tp> 
    inline typename 
    __gnu_cxx::__enable_if<__is_byte<_Tp>::__value, void>::__type 
    __fill_a(_Tp* __first, _Tp* __last, const _Tp& __c) 
    { 
     const _Tp __tmp = __c; 
     __builtin_memset(__first, static_cast<unsigned char>(__tmp), 
     __last - __first); 
    } 
# 719 "c:\\tdm-gcc-32\\lib\\gcc\\mingw32\\4.8.1\\include\\c++\\bits\\stl_algoba 
e.h" 3 
    template<typename _ForwardIterator, typename _Tp> 
    inline void 
    fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) 
    { 



     ; 

     std::__fill_a(std::__niter_base(__first), std::__niter_base(__last), 
     __value); 
    } 

    template<typename _OutputIterator, typename _Size, typename _Tp> 
    inline typename 
    __gnu_cxx::__enable_if<!__is_scalar<_Tp>::__value, _OutputIterator>::__type 
    __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value) 
    { 
     for (__decltype(__n + 0) __niter = __n; 
    __niter > 0; --__niter, ++__first) 
*__first = __value; 
     return __first; 
    } 

    template<typename _OutputIterator, typename _Size, typename _Tp> 
    inline typename 
    __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, _OutputIterator>::__type 
    __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value) 
    { 
     const _Tp __tmp = __value; 
     for (__decltype(__n + 0) __niter = __n; 
    __niter > 0; --__niter, ++__first) 
*__first = __tmp; 
     return __first; 
    } 

    template<typename _Size, typename _Tp> 
    inline typename 
    __gnu_cxx::__enable_if<__is_byte<_Tp>::__value, _Tp*>::__type 
    __fill_n_a(_Tp* __first, _Size __n, const _Tp& __c) 
    { 
     std::__fill_a(__first, __first + __n, __c); 
     return __first + __n; 
    } 
# 779 "c:\\tdm-gcc-32\\lib\\gcc\\mingw32\\4.8.1\\include\\c++\\bits\\stl_algoba 
e.h" 3 
    template<typename _OI, typename _Size, typename _Tp> 
    inline _OI 
    fill_n(_OI __first, _Size __n, const _Tp& __value) 
    { 



     return _OI(std::__fill_n_a(std::__niter_base(__first), __n, __value)); 
    } 

    template<bool _BoolType> 
    struct __equal 
    { 
     template<typename _II1, typename _II2> 
     static bool 
     equal(_II1 __first1, _II1 __last1, _II2 __first2) 
     { 
    for (; __first1 != __last1; ++__first1, ++__first2) 
    if (!(*__first1 == *__first2)) 
     return false; 
    return true; 
} 
    }; 

    template<> 
    struct __equal<true> 
    { 
     template<typename _Tp> 
     static bool 
     equal(const _Tp* __first1, const _Tp* __last1, const _Tp* __first2) 
     { 
    return !__builtin_memcmp(__first1, __first2, sizeof(_Tp) 
     * (__last1 - __first1)); 
} 
    }; 

    template<typename _II1, typename _II2> 
    inline bool 
    __equal_aux(_II1 __first1, _II1 __last1, _II2 __first2) 
    { 
     typedef typename iterator_traits<_II1>::value_type _ValueType1; 
     typedef typename iterator_traits<_II2>::value_type _ValueType2; 
     const bool __simple = ((__is_integer<_ValueType1>::__value 
     || __is_pointer<_ValueType1>::__value) 
         && __is_pointer<_II1>::__value 
         && __is_pointer<_II2>::__value 
     && __are_same<_ValueType1, _ValueType2>::__value); 

     return std::__equal<__simple>::equal(__first1, __last1, __first2); 
    } 


    template<typename, typename> 
    struct __lc_rai 
    { 
     template<typename _II1, typename _II2> 
     static _II1 
     __newlast1(_II1, _II1 __last1, _II2, _II2) 
     { return __last1; } 

     template<typename _II> 
     static bool 
     __cnd2(_II __first, _II __last) 
     { return __first != __last; } 
    }; 

    template<> 
    struct __lc_rai<random_access_iterator_tag, random_access_iterator_tag> 
    { 
     template<typename _RAI1, typename _RAI2> 
     static _RAI1 
     __newlast1(_RAI1 __first1, _RAI1 __last1, 
    _RAI2 __first2, _RAI2 __last2) 
     { 
    const typename iterator_traits<_RAI1>::difference_type 
    __diff1 = __last1 - __first1; 
    const typename iterator_traits<_RAI2>::difference_type 
    __diff2 = __last2 - __first2; 
    return __diff2 < __diff1 ? __first1 + __diff2 : __last1; 
} 

     template<typename _RAI> 
     static bool 
     __cnd2(_RAI, _RAI) 
     { return true; } 
    }; 

    template<bool _BoolType> 
    struct __lexicographical_compare 
    { 
     template<typename _II1, typename _II2> 
     static bool __lc(_II1, _II1, _II2, _II2); 
    }; 

    template<bool _BoolType> 
    template<typename _II1, typename _II2> 
     bool 
     __lexicographical_compare<_BoolType>:: 
     __lc(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) 
     { 
typedef typename iterator_traits<_II1>::iterator_category _Category1; 
typedef typename iterator_traits<_II2>::iterator_category _Category2; 
typedef std::__lc_rai<_Category1, _Category2> __rai_type; 

__last1 = __rai_type::__newlast1(__first1, __last1, 
     __first2, __last2); 
for (; __first1 != __last1 && __rai_type::__cnd2(__first2, __last2); 
     ++__first1, ++__first2) 
    { 
    if (*__first1 < *__first2) 
     return true; 
    if (*__first2 < *__first1) 
     return false; 
    } 
return __first1 == __last1 && __first2 != __last2; 
     } 

    template<> 
    struct __lexicographical_compare<true> 
    { 
     template<typename _Tp, typename _Up> 
     static bool 
     __lc(const _Tp* __first1, const _Tp* __last1, 
     const _Up* __first2, const _Up* __last2) 
{ 
    const size_t __len1 = __last1 - __first1; 
    const size_t __len2 = __last2 - __first2; 
    const int __result = __builtin_memcmp(__first1, __first2, 
     std::min(__len1, __len2)); 
    return __result != 0 ? __result < 0 : __len1 < __len2; 
} 
    }; 

    template<typename _II1, typename _II2> 
    inline bool 
    __lexicographical_compare_aux(_II1 __first1, _II1 __last1, 
     _II2 __first2, _II2 __last2) 
    { 
     typedef typename iterator_traits<_II1>::value_type _ValueType1; 
     typedef typename iterator_traits<_II2>::value_type _ValueType2; 
     const bool __simple = 
(__is_byte<_ValueType1>::__value && __is_byte<_ValueType2>::__value 
    && !__gnu_cxx::__numeric_traits<_ValueType1>::__is_signed 
    && !__gnu_cxx::__numeric_traits<_ValueType2>::__is_signed 
    && __is_pointer<_II1>::__value 
    && __is_pointer<_II2>::__value); 

     return std::__lexicographical_compare<__simple>::__lc(__first1, __last1, 
      __first2, __last2); 
    } 
# 941 "c:\\tdm-gcc-32\\lib\\gcc\\mingw32\\4.8.1\\include\\c++\\bits\\stl_algoba 
e.h" 3 
    template<typename _ForwardIterator, typename _Tp> 
    _ForwardIterator 
    lower_bound(_ForwardIterator __first, _ForwardIterator __last, 
    const _Tp& __val) 
    { 




     typedef t 
+2

請刪除您的錯誤信息打印輸出的動畫gif – Simson 2014-08-28 11:13:00

+0

問題是,這是一個永無止境的滾動,我不能讓它停止考慮複製和粘貼任何東西 – CoppolaEmilio 2014-08-28 11:13:31

+1

使用'g ++ Smail.cpp' – user685684 2014-08-28 11:15:27

回答

1

「cpp」代表C預處理器。您正在可視化程序的預處理版本,以及它包含(和遞歸)的iostream頭的源代碼。

0

作爲user685684的評論所說,取代 「CPP small.cpp」 爲 「C++ small.cpp」 固定的問題和奇怪的錯誤是沒有更長的時間。

+1

至於爲什麼:「cpp」代表C PreProcessor。您正在可視化程序的預處理版本,以及它包含的「iostream」頭的源代碼(以及遞歸)。 – Quentin 2014-08-28 11:22:29

+0

感謝您的解釋,如果您將其添加爲答案,我會很樂意檢查它作爲我正在尋找的解決方案。我不太明白爲什麼每個人都會低估它:S – CoppolaEmilio 2014-08-28 11:26:13

+0

他們或者被gif激怒,或者是因爲這是一種「一次性使用的問題」,這可能不會幫助其他人。 – Quentin 2014-08-28 11:28:58