User Changes 2.2.2

From Free Pascal wiki
Revision as of 15:03, 31 May 2008 by Jonas (talk | contribs) (+ FPCMacOSAll -> MacOSAll change)
Jump to navigationJump to search

About this page

Below you can find a list of intentional changes between the the 2.2.0 release and the 2.2.2 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

Char to WideChar conversions and vice versa

  • Old behaviour: Type conversions between chars and widechars did not cause any translations of the data.
  • New behaviour: A char to a widechar conversion or vice versa now triggers the widestring manager, and converts the data from ansichar to widechar or the other way around. If a converted widechar is not representable in a single char, the result of the conversion is always '?'
  • Example: char_var:=char(widechar_var); used to put the lower 8 bits of widechar_var into char_var, while now the widestring manager is called to translate widechar_var from UTF-16 to the active code page.
  • Reason: Bug report 7758, and consistency with conversions between shortstrings/ansistrings and widestrings.
  • Effect: If you previously typecasted chars to widechars or the other way around (possibly via parameter passing or assignments), these type conversions will now cause the data to be translated.
  • Remedy: If you do not want any translation to be performed, add an additional type conversion to an integer type in between, e.g. char_var:=char(word(widechar_var));


Typecasting ordinal constants to complex types (records, arrays, sets)

  • Old behaviour: It was possible to typecast ordinal constants into records/sets/arrays at compile time.
  • New behaviour: Such type casts now always give a compile time error.
  • Example: type tr = record a,b,c,d: byte end; ... writeln(tr($12345678).b); use to be accepted by the type checking code, but now it isn't anymore.
  • Reason: Many parts of the compiler could not really deal with this sort of code and either generated wrong code or caused internal errors. This sort of code is not allowed by Delphi either.
  • Remedy: Assign the value first to an ordinal variable of the appropriate type and then perform the type cast using this variable.


Internal format of sets

  • Change: The internal storage format of sets has been changed compared to earlier versions of FPC. Both the size and the content of sets can be different in FPC 2.2.2 compared to what they were before.
  • Reason: Store sets using less space, Delphi compatibility.
  • Remedy: If you have binary files containing sets which you would like to convert to the new format, you can use the setconv unit available from the FTP site. This archive also contains an example on how to use it.


Mac OS X

FPCMacOSAll unit

  • Old behaviour: The included Common Pascal Interfaces unit containing all translated APIs was called FPCMacOSAll.
  • New behaviour: This unit is now called MacOSAll.
  • Reason: The Common Pascal Interfaces can be used with FPC, GPC and MW Pascal. Since the FPCMacOSAll, GPCMacOSAll and MWMacOSAll units all included basically the same functionality, the different names required useless ifdef's in programs compilable with several of these compilers.
  • Remedy: Replace uses FPCMacOSAll with uses MacOSAll. You can protect this change with {$if not defined(VER2_2_0) and not defined(VER2_0_4)} for backwards compatibility purposes.