Sign in Join
Wiki copytemporary

User Changes 2.2.2: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: User Changes 2.2.2

OldNewLine
1+## About this page
2+
3+Below you can find a list of intentional changes between the [[User Changes 2.2.0|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.
4+
5+## All systems
6+
7+### Char to WideChar conversions and vice versa
8+
9+- **Old behaviour**: Type conversions between chars and widechars did not cause any translations of the data.
10+- **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 '?'
11+- **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.
12+- **Reason**: [Bug report 7758](http://www.freepascal.org/mantis/view.php?id=7758), and consistency with conversions between shortstrings/ansistrings and widestrings.
13+- **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.
14+- **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));*
15+
16+### Typecasting ordinal constants to complex types (records, arrays, sets)
17+
18+- **Old behaviour**: It was possible to typecast ordinal constants into records/sets/arrays at compile time.
19+- **New behaviour**: Such type casts now always give a compile time error.
20+- **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.
21+- **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.
22+- **Remedy**: Assign the value first to an ordinal variable of the appropriate type and then perform the type cast using this variable.
23+
24+### Internal format of sets
25+
26+- **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.
27+- **Reason**: Store sets in less space, Delphi compatibility.
28+- **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](ftp://ftp.freepascal.org/pub/fpc/contrib/setconv.zip). This archive also contains an example on how to use it.
29+
30+### Restructuring of packages
31+
32+- **Change**: FPC packages have been restructured and some units are installed in different directories than in the past. If trying to overwrite an older version with the new one by installing the new version into the directory previously used for the older version, old units may be left on your disk and FPC may potentially find the wrong (old) version of these units.
33+- **Reason**: The new structure allows easier maintenance and use of the coming package manager.
34+- **Remedy**: On Unix-like platforms, this change should not cause any problems nor require any actions from you. On Windows, the easy solution is using a different installation directory for the new version, or to remove the existing installation first if you want to use the same directory for the new version. If this is not possible, you can always locate older units by looking for .ppu,.o and possibly .a files built earlier than in year 2008.
35+
36+## All Unix-like systems
37+
38+### Name mangling of exported library functions
39+
40+- **Old behaviour**: If no export name was specified, the identifier as it appeared in the source code was used as exported name
41+- **New behaviour**: If no export name is specified, then
42+ - If the routine is declared using the `mwpascal` or `cdecl` calling convention, the exported name will be mangled like a C compiler on the target platform would do;
43+ - If the routine is declared using the `cppdecl` calling convention, the exported name will be mangled like a C++ compiler on the target platform would do;
44+ - Otherwise the old behaviour is kept.
45+- **Example**: `procedure test; cdecl; ... exports test;` in a library used to always export that procedure as `test`. Now it will be exported as `_test` on unix-like platforms where C compilers implicitly add an underscore to all global symbol names (such as Mac OS X).
46+- **Reason**: This avoids the requirement to use ifdefs to support proper exporting of `cdecl` routines from Pascal libraries to C programs on different platforms.
47+- **Remedy**: If you need a particular export name, use the `test name 'sometestname';` export syntax.
48+
49+### Exporting library variables and functions
50+
51+- **Old behaviour**: All publicly visible procedures, functions and variables in units used by a library were automatically exported by that library on Unix-lke systems.
52+- **New behaviour**: Only those procedures, functions and variables appearing in the `exports` section of a library are now exported.
53+- **Reason**: The old behaviour polluted the symbol namespace too much, and caused many more symbols to be exported than what was intended (such as the entire FPC run time library).
54+- **Remedy**: Add the names of the procedures, functions and variables you want to export to the library's `export` statement. Note that at this time, variables can only be exported using a name with which they were declared.
55+
56+## Mac OS X
57+
58+### FPCMacOSAll unit
59+
60+- **Old behaviour**: The included Common Pascal Interfaces unit containing all translated APIs was called *FPCMacOSAll*.
61+- **New behaviour**: This unit is now called *MacOSAll*.
62+- **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 ifdefs in programs compilable with several of these compilers.
63+- **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.
64+
65+### Unhandled exceptions on Mac OS X/Intel (run time error 207)
66+
67+- **Old behaviour**: Previous FPC versions did not enable arithmetic exceptions for the SSE unit of Intel Macs. This SSE unit is used by most of the system libraries to perform floating point calculations. This means that floating point errors in the system libraries were silently ignored (just like they are for C programs, as these exceptions are disabled there by default as well).
68+- **New behaviour**: FPC now enables all SSE floating point exceptions at startup. The result is that some (mostly GUI) applications now terminate with a "run time error 207".
69+- **Reason**: The FPC programming model includes reporting all floating point exceptions as they happen. Many existing programs expect this, since this is also the behaviour on other platforms.
70+- **Remedy**: Add the `math` unit to your uses clause and add the following statement at the beginning of your program: `SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision])`. Note that this will disable floating point exceptions in all code, not just in the system libraries. The reason this is not necessary on PowerPC is that the macpas unit, which is automatically included in any program using one of the Common Pascal Interfaces units such as `MacOSAll`, already contains code to disable the exceptions for PowerPC. Similar code for Intel will be added to that unit in a future release, so you will not have to add it yourself anymore (see <http://bugs.freepascal.org/view.php?id=11516>).
71+
72+## WinCE
73+
74+### Windows unit
75+
76+- **Old behaviour**: All WinCE API interfaces were contained in the Windows unit.
77+- **New behaviour**: The Windows unit contains only the basic API interfaces. Other API interfaces are contained in separate units like aygshell, commctrl, shellapi, etc.
78+- **Reason**: Make the WinCE unit names consistent with the Win32/64 unit names.
79+- **Remedy**: Add additional units to uses clause to fix compile time errors. You can protect this change with *{\$ifndef VER2_2_0}* for backwards compatibility purposes.
80+
81+## Previous release notes
82+
83+---
84+*From the Free Pascal wiki, page "User Changes 2.2.2", as it stood on 2015-05-09 after a change by Socke, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
85+Category: FPC User Changes by release
86+Category: Release Notes

Back to history