编程时如何缩短控制台上显示的错误代码

How do you shorten the errorcode shown on the console while programming

我有一个问题,当我在编程时犯了一个更大的错误,我得到的错误每个占用 100 行。有用的错误代码在最上面,而其余的看起来像是相同无用文本的 copy/paste,类似于:

In file included from c:\mingw\lib\gcc\mingw32.2.0\include\c++\iostream:39,
                 from 9.2.cpp:1:
c:\mingw\lib\gcc\mingw32.2.0\include\c++\ostream:682:5: note: candidate: 'template<class _Ostream, class _Tp> typename std::enable_if<std::__and_<std::__not
_<std::is_lvalue_reference<_Tp> >, std::__is_convertible_to_basic_ostream<_Ostream>, std::__is_insertable<typename std::__is_convertible_to_basic_ostream<_Tp>
::__ostream_type, const _Tp&, void> >::value, typename std::__is_convertible_to_basic_ostream<_Tp>::__ostream_type>::type std::operator<<(_Ostream&&, const _T
p&)'

我该怎么做才能让 window omit this part? I know what the problem is, but I don't want the same line of text spam my entire 一直window。

您可以使用此批处理文件获取错误代码:

@echo off
pushd %~dp0
The command generated the long error 1>nul 2>errors.txt
set /p errorcode=<errors.txt
echo %errorcode%
del /f /q errors.txt
popd
goto :eof 

运行 从 cmd 中输入,您将得到错误代码。