Am 26.08.2021 um 10:10 schrieb LacaK via fpc-pascal:
Thank you for both answers!

Please note that you won't be able to catch such an exception with the type from within the application, e.g.:

=== code begin ===

try
  SomeLibraryFunction;
except
  on e: TMyObject do
     Whatever;
  else
     WhateverElse;
end;

=== code end ===

The above code would go to the first branch *inside* your library, but it will *always* go to the else-branch outside your library, cause the comparison is done on the pointer to the VMT (the class type) which will be *different* between library and application (even if you use the same unit!). This is one of the main reasons why dynamic packages are needed for comfortable use of libraries in Object Pascal, because it allows such types to be shared across module boundaries.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to