How do I get Visual Studio 2013 to display the exit code in the Output window when a program completes if I don't have access to main
?
如果程序完成,如果我无法访问main,如何让Visual Studio 2013在“输出”窗口中显示退出代码?
I'm using Boost test to run some tests. main
is defined by the framework so I cannot simply print the exit code to stdout prior to completion. When all tests pass, the exit code is 0 otherwise it is generally 200 or 201.
我正在使用Boost测试来运行一些测试。 main由框架定义,所以我不能简单地在完成之前将退出代码打印到stdout。当所有测试通过时,退出代码为0,否则通常为200或201。
When I run the tests in Xcode on OS X the value of the exit code is displayed in the console automatically. I'd like Visual Studio to do the same if possible.
当我在OS X上的Xcode中运行测试时,退出代码的值会自动显示在控制台中。如果可能的话,我希望Visual Studio能够做同样的事情。
1 个解决方案
#1
There is nothing in built-in settings for Visual Studio that will do this directly.
Visual Studio的内置设置中没有任何内容可以直接执行此操作。
However, you could define an alternate entry point for your application using the /ENTRY
linker setting (Property Pages->Linker->Advanced->Entry Point
). Making your own main function, you could call the main function from the test library, and print out its return code in your function. You would then have the option of returning its return code from your main function (or some other code of your choosing).
但是,您可以使用/ ENTRY链接器设置(属性页 - >链接器 - >高级 - >入口点)为应用程序定义备用入口点。创建自己的main函数,可以从测试库中调用main函数,并在函数中打印出它的返回代码。然后,您可以选择从主函数(或您选择的其他代码)返回其返回码。
#1
There is nothing in built-in settings for Visual Studio that will do this directly.
Visual Studio的内置设置中没有任何内容可以直接执行此操作。
However, you could define an alternate entry point for your application using the /ENTRY
linker setting (Property Pages->Linker->Advanced->Entry Point
). Making your own main function, you could call the main function from the test library, and print out its return code in your function. You would then have the option of returning its return code from your main function (or some other code of your choosing).
但是,您可以使用/ ENTRY链接器设置(属性页 - >链接器 - >高级 - >入口点)为应用程序定义备用入口点。创建自己的main函数,可以从测试库中调用main函数,并在函数中打印出它的返回代码。然后,您可以选择从主函数(或您选择的其他代码)返回其返回码。