Comments (8)
OutputDebugString
isn't just for GUI apps, it works for console apps too. You can think of Windows apps as always having two different output streams - standard out and debug out - and one of them is only relevant while you have a debugger attached. Debugging-related messages should always go to OutputDebugString
and normal input/output (such as piping between parent and child process) should be unaffected by it. Perhaps it should be configurable?
from corrade.
IsDebuggerPresent()
Currently testing in vs2019 - seems to work fine with RelWithDebInfo, and doesn't return true if no debugger attached.
from corrade.
So it means ... if I run with F5, it says true
, if I run with Ctrl-F5, it says false
? In both cases I'd like the output to be shown.
from corrade.
if I run with F5, it says true, if I run with Ctrl-F5, it says false
Yup, I think that's exactly the case with IsDebuggerPresent()
(you could of course do Ctrl-F5 and then reattach the debugger, but I don't think that's what you're implying..?)
from corrade.
I thought I could use IsDebuggerPresent()
to check if the app is being run from within Visual Studio. Because I imagine, if the app is run outside of the IDE, people would want the debug messages to be again in the standard output (or not?).
Well, Windows is not my native system, so I'm just guessing -- but I imagine everything sent to OutputDebugString
is lost when you don't have the VS debugger attached? Or does it go somewhere else? System log?
from corrade.
I tried here with MinGW-w64 GCC/GDB on Windows, using both CLion and the MSYS2 build of Qt Creator (I don't use VS because it can't be used with GCC and because it's really bloated).
IsDebuggerPresent()
returns false when run normally through the IDE, and true when run with GDB attached. This happens both in Debug and Release (I don't use the other CMake build types).
Notes:
- Qt Creator manages to grab the app's output anyway, I didn't need to do anything over there for some reason.
- However, in CLion, I had to open its settings registry (the equivalent of Firefox'
about:config
screen), and switchrun.processes.with.pty
to false to see output when running an app normally (output when debugging worked out of the box).
from corrade.
Note that you can just always send output to OutputDebugString and, when the application is running outside of Visual Studio, see it using the Sysinternals tool DebugView - see the download page. It was developed outside Microsoft but Microsoft acquired them. I've been using it for years - it's got some handy redirection and filtering capabilities, but you can also run it from the CMD CLI and redirect its output to a file.
from corrade.
OutputDebugString()
is apparently implemented via exceptions, so I imagine using it always could have some bad perf implications compared to the regular stdout.
OTOH, thanks to that tweet now I probably know how to catch it even without VS debugger or DebugView attached :)
from corrade.
Related Issues (20)
- Corrade with BUILD_TESTS=ON compilation error: call to non-‘constexpr’ function HOT 5
- Error when installing via HunterGate HOT 7
- Prefix cmake options with CORRADE_ HOT 4
- Windows: inconsistent redefinition of _aligned_malloc HOT 3
- Corrade adds /wd*** warning disablements to "clang.exe" on windows. HOT 1
- Building Corrade with -std=c++20 causes errors inside MinGW <numbers> header HOT 3
- Corrade fails to compile with emscripten 3.1.22 HOT 4
- Opt-in to native UTF-8 support for OS interaction on Windows
- std::tuple_size / tuple_element specializations for Corrade containers HOT 1
- error: cannot initialize a variable of type 'const char *const' with an rvalue of type 'int' HOT 3
- Optimizing compilation time for the test suite -- an analysis HOT 3
- Interconnect - Slots are not called according to their record order HOT 1
- V8::Zone Allocator HOT 1
- NEON code does not build on armv7 HOT 2
- what to set CORRADE_INCLUDE_DIR to for in-source-builds HOT 2
- JsonToken::asObject() odd behavior with empty objects HOT 2
- New Release HOT 1
- Broken Interconnect on Clang-CL 16.0.5 HOT 9
- Packaging location of GDB script files HOT 8
- Container::Pointer does not work with forward declaration anymore HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from corrade.