If I replace the 'LineNr = 0' instances with 'LineNr = #PB_Compiler_Line', I get 'Declare doesn't match with real Procedure' which seems like a bug to me. Can anyone confirm or clear this up?
kpeters58 wrote:If I replace the 'LineNr = 0' instances with 'LineNr = #PB_Compiler_Line', I get 'Declare doesn't match with real Procedure' which seems like a bug to me. Can anyone confirm or clear this up?
The constant #PB_Compiler_Line gets replaced by the number of the line in each line where it occurs. This means since the two lines you indicated are in fact on different lines, they each indicate that 'LineNr' will receive a different default value. The compiler error message is thus correct, no bug.
@IdeasVacuum: If it is written as you suggest you don't need the 'Declare' portion at all.
@kpeters58: Why do you use the compiler constants in the procedure's parameter list?
If you are wanting those values to indicate where each invocation of DBError() occurs it will not function as you intend it to do so. This is necause those values used as defaults in the parameter list are substtuted at compile time. What you would want to do is use those compiler constants in each invocation of DBError(). Still, another option is to use it in both places.
This could be considered a feature request. In the D programming language (and maybe others too) that's exactly how it works. If you use __LINE__ etc. as default arguments of a function they will be evaluated at the call (or better 'instantiation' because D has templates). It might seem 'incorrect' but that's usually just what you want to do, the 'correct' way is of no use.