Hi,
Is there a way to know at run-time if $D ($DEBUGINFO) is on?
I tried
{$IFDEF DEBUGINFO}Somecode{$ENDIF} // Somecode is not executed (appears grayed in the editor)
{$IFDEF $DEBUGINFO}Somecode{$ENDIF} // Compiler doesn't allow it
The keywords in your request are
at run time. As you probably already know, to find out at compile time, you can test if an option or directive is "active".
Under Windows, to determine
at run time if an executable was compiled with debugging information, two possibilities come to mind.
1. Examine the value of the "Pointer to symbol table" field found in the executable's file header. If the debugging information is _embedded_ in the executable (it usually is), that field will be non-zero.
2. if the debugging information is _not_ embedded in the executable, IOW, it is in a separate file, there is _probably_ an indication of that somewhere in the PE file (which is the program.) I cannot tell you what field(s) in the PE file should be checked because I never tell the compiler to put the debugging information in a separate file but, it's quite likely there is something in the executable that indicates that situation.
NOTE: most C compilers, notably MSVC, will put a reference to the external PDB file in the DEBUG directory but I don't know if FPC does that or not when it is told to put the debug symbols in a separate file.
HTH.