Recent

Author Topic: Equivalent to Raising Exceptions in Free Pascal  (Read 669 times)

bobby6478

  • New Member
  • *
  • Posts: 17
Equivalent to Raising Exceptions in Free Pascal
« on: October 25, 2019, 09:20:23 pm »
As part of a project that I am working on, I am using thousands of lines of free pascal pascal written without the {$mode OBJFPC}{H+} modifier added to the beginning, and thus the statement raise is not recognized because the project is compiled in FPC mode. One option is to add {$mode OBJFPC}{H+} to the beginning of each unit. This certainly converts all small integers to long integers (as integer becomes takes this redefinition when moving to OBJFPC, and all of the code that I have uses integers, it never specifies what length) but I can only assume it may have some unpredictable consequences once all of the errors are resolved. So my question is, how are errors created in FPC? I cannot raise an exception but errors must still exist in FPC for the code to know to stop. Can I do something equivalent to that? 

Thaddy

  • Hero Member
  • *****
  • Posts: 9425
Re: Equivalent to Raising Exceptions in Free Pascal
« Reply #1 on: October 25, 2019, 10:10:54 pm »
{$I-} and IOResult...and Halt()
« Last Edit: October 25, 2019, 10:13:20 pm by Thaddy »
also related to equus asinus.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 686
Re: Equivalent to Raising Exceptions in Free Pascal
« Reply #2 on: October 25, 2019, 10:23:06 pm »
You can enable support for exceptions separately via {$modeswitch exceptions}

Thaddy

  • Hero Member
  • *****
  • Posts: 9425
Re: Equivalent to Raising Exceptions in Free Pascal
« Reply #3 on: October 25, 2019, 10:39:10 pm »
You can enable support for exceptions separately via {$modeswitch exceptions}
As I read it, because of the integer remark, it is old code. pre-exceptions.
also related to equus asinus.

bobby6478

  • New Member
  • *
  • Posts: 17
Re: Equivalent to Raising Exceptions in Free Pascal
« Reply #4 on: October 25, 2019, 10:46:05 pm »
You can enable support for exceptions separately via {$modeswitch exceptions}

That did the trick, thanks!