简体   繁体   中英

Visual Studio - how to display exit code in output window without access to `main`

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 ?

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.

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.

There is nothing in built-in settings for Visual Studio that will do this directly.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM