I never thought abut this before, but today I noticed that the "Release" target of one of my projects turns off the "typed @ parameter" compiler option while the "Debug" target turns it on.

I never thought abut this before, but today I noticed that the "Release" target of one of my projects turns off the "typed @ parameter" compiler option while the "Debug" target turns it on.

I know that it is supposed to check whether the value passed to a pointer type parameter matches the parameter's declaration and I always thought that to be a compile time check, not a run time check. So, if that's the case, why would I ever want to turn off this option?

Comments

  1. For compatibility with original Pascal of 1970-s and many Pascal/Delphi versions since that.
    Default setting is that Delph has no type checking for pointers values.
    There were a number of libraries ( for example OTL ) which just did not compiled in $T+ mode until intentionally checking and fixing it

    ReplyDelete
  2. One annoying thing of turning it on in library code especially is that referencing a resource string returns an untyped pointer rather than a PResString, so calls to exception constructors in the idiomatic style break without an additional cast (and hard casting rather defeats the object of stronger typing in the first place). It can also lead to needing various casts in Windows API calls (e.g. when creating a DIB through API calls) though that is arguably a good thing.

    ReplyDelete

Post a Comment