Hello. I'd like to have:
version (D_DebugInfo)
{}
else
{
version = enableFeatureThatIsAnnoyingWhenDebugging;
}
Is there a way to know if debug info is being emitted when compiling?
"debug" is not cutting it because sometimes you really need to debug with or without -debug, and with or without -O.
I would want -g.
Comment #1 by dkorpel — 2022-11-11T12:07:40Z
There's now precedence for version identifiers based on codegen flags with `D_Optimized`: https://github.com/dlang/dmd/pull/14245
Still, I would like to have solid rationale before adding another.
What kind of feature is annoying when debugging?
Also, can't you pass `-g -version=disableFeatureThatIsAnnoyingWhenDebugging`?
Comment #2 by aliloko — 2022-11-11T13:03:17Z
Dplug software has a mouse hook that is active to allow using the mouse wheel when dragging outside of the window. Others OSes can do that, but Windows needs a mouse hook.
When debugging, this is extra slow, but in normal times it is invisible. Hence, for practicality it's better to disable this.
- D_Optimized is obviously not the same as D_Optimized, it's frequent to want to debug optimized builds
- I don't see why -g would one of the only flags you can detect. -g is the closest flag to "I will debug this interactively".
> Also, can't you pass `-g -version=disableFeatureThatIsAnnoyingWhenDebugging`?
No. That doesn't solve the problem, as we use dub, and version identifiers are set by configurations not build types.
Comment #3 by aliloko — 2022-11-11T13:04:01Z
> D_Optimized is obviously not the same as D_Optimized
Corerection not the same as D_DebugInfo*
Comment #4 by aliloko — 2022-11-11T13:04:51Z
> you can detect
you couldn't* detect
Comment #5 by apz28 — 2022-11-11T14:09:23Z
Why D don't create corresponding versions for all simple flags?
Some sample flags
DMD -g -debug -inline
will have following defined versions, Dflag can be shorten to Df
Dflag_g Dflag_debug Dflag_inline
so usage is
version(Dflag_g)
version(Dflag_debug)
version(Dflag_inline)
Comment #6 by aliloko — 2022-11-13T01:08:24Z
That's not what this bug is about, it's just about -g
Comment #7 by robert.schadek — 2024-12-13T19:25:07Z