我有问题,当我在编程时犯了一个更大的错误时,我会得到每个占用100行的错误。有用的错误代码在顶部,而其余的看起来像是相同的无用文本的复制/粘贴,类似于:
In file included from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\iostream:39,
from 9.2.cpp:1:
c:\mingw\lib\gcc\mingw32\8.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&)'
如何使command-prompt窗口省略此部分?我知道问题出在哪里,但是我不希望我的整个cmd窗口始终出现同一行文本垃圾邮件。
您可以使用此批处理文件获取错误代码:
@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运行它,您将获得错误代码。