Create an empty project with this in main.cpp
c++
#include <iostream>
int main(int argc, char** argv) {
std::cout << " error exception : " << std::endl;
exit(0);
}
Call this: RetVal.exe
Create a new project and add a Post-Build event where you run this executable
Now visual studio will ALWAYS tell this:
output:
EXEC : error exception:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(153,5): error MSB3073:
The command "C:\Perforce\Projects\Retval2\x64\Debug\RetVal.exe
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(153,5): error MSB3073:
:VCEnd" exited with code -1.
This works with any both Visual Studio 2015 and 2019.
EDIT: The reason for this is that VisualStudio IDE will interpret lines in the output as Viorel describes below.
Note that if you run this in a bat file "echo %errorlevel%" will of course give 0 as output.
The reason we found this was that we wanted to run gtest as a post-build event and one of the test cases outputs "error exception : " (as expected).
We interpreted it as: gtest returned -1 while it actually returns 0.
All it actually said was that ":VCEnd" exited with code -1".
A bit confusing perhaps but still working as intended I guess.