Difference between revisions of "User Changes 2.2.0"

From Free Pascal wiki
Jump to navigationJump to search
(commented out socket/file removal)
(fourcharcode info)
Line 31: Line 31:
 
* '''Remedy''': remove all calls to '''RTLEventStartWait''' from your code, they are no longer necessary
 
* '''Remedy''': remove all calls to '''RTLEventStartWait''' from your code, they are no longer necessary
  
 +
=== MacPas OSType/FourCharCode ===
 +
* '''Old behaviour''': strings could be implicitly converted to 32 bit integer values by the compiler in macpas mode (i.e., without a typecast)
 +
* '''New behaviour''': only constant strings of exactly 4 characters can be implicitly converted to 32 bit integers
 +
* '''Example''': ''dword1:=stringvar;'' and ''dword1:='ab';'' used to compile in macpas mode, now this will give a compile time error. ''dword1:='abcd';'' will still work, however.
 +
* '''Reason''': although those statements (and others, like indexing a dword as an array) are allowed by e.g. Metrowerks Pascal, they go against all Pascal typing rules. Some, like the indexing of dwords as arrays, are also inherently endian-unsafe.
 +
* '''Effect''': code using such constructs will no longer compile
 +
* '''Workaround''': use the ''function FOUR_CHAR_CODE(const literal: string): LongWord;'' function in places where you still want to convert strings to OSType. This function will also take care of endian issues.
  
 
== Unix ==
 
== Unix ==

Revision as of 20:42, 14 January 2007

About this page

Below you can find a list of intentional changes since the FPC 2.0.4 release which can change the behaviour of previously working code, along with why these changes were performed and how you can adapt your code if you are affected by them.

All systems

Floating point constants

  • Old behaviour: all floating point constants were considered to be of the highest precision available on the target platform
  • New behaviour: floating point constants are now considered to be of the lowest precision which doesn't cause data loss
  • Example: 2.0 can be represented exactly using single, so it will be parsed as a single. 1.1 cannot be represented exactly in any IEEE floating point format, so it will be considered to be of the largest floating point type available
  • Reason: Delphi compatibility, avoid wrong precision-loss warnings when doing things like "singler:=single1*2.0"
  • Effect: some expressions, in particular divisions of integer values by floating point constants, may now default to a lower precision than in the past.
  • Remedy: if more precision is required than the default, typecast the floating point constant to a higher precision type, e.g. extended(2.0)


RTLEventStartWait

  • Old behaviour: you had to call RTLEventStartWait before calling RTLEventWaitFor
  • New behaviour: RTLEventStartWait has been removed from the RTL
  • Example: self-explanatory
  • Reason: RTLEventStartWait only existed because the Unix implementation did not support persistent events. Now it does, so this routine is no longer necessary.
  • Effect: code calling RTLEventStartWait will no longer compile
  • Remedy: remove all calls to RTLEventStartWait from your code, they are no longer necessary

MacPas OSType/FourCharCode

  • Old behaviour: strings could be implicitly converted to 32 bit integer values by the compiler in macpas mode (i.e., without a typecast)
  • New behaviour: only constant strings of exactly 4 characters can be implicitly converted to 32 bit integers
  • Example: dword1:=stringvar; and dword1:='ab'; used to compile in macpas mode, now this will give a compile time error. dword1:='abcd'; will still work, however.
  • Reason: although those statements (and others, like indexing a dword as an array) are allowed by e.g. Metrowerks Pascal, they go against all Pascal typing rules. Some, like the indexing of dwords as arrays, are also inherently endian-unsafe.
  • Effect: code using such constructs will no longer compile
  • Workaround: use the function FOUR_CHAR_CODE(const literal: string): LongWord; function in places where you still want to convert strings to OSType. This function will also take care of endian issues.

Unix

RTLEvent persistence

  • Old behaviour: calling RTLEventSetEvent before another thread was waiting caused the event to be lost
  • New behaviour: RTLEventSetEvent is now persistent, i.e. it's possible to send the event before another thread starts waiting and it won't be lost (calling RTLEventSetEvent multiple times does not cause multiple events to add up in a queue)
  • Example: see above
  • Reason: compatibility with behaviour under Windows
  • Effect: see above
  • Remedy: for non-persistent events, use the pthread_cond_signal/wait and related routines directly


PowerPC

Floating point calculations

  • Old behaviour: all floating point calculations used to be performed using double precision
  • New behaviour: floating point calculations involving only single precision values are now performed using single precision
  • Example: singler:=(single1/single2+single3)*single4 used to be calculated using double precision, and only be rounded back to single precision during the assignment. Now the intermediate calculations will also be done using single precision.
  • Reason: speed (in particular single precision divisions are much faster than double precision ones), compatibility with gcc behaviour
  • Effect & Remedy: see "Floating point constants" section