Sign in Join
Wiki copytemporary

User Changes 2.2.0: what changed

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

Title: User Changes 2.2.0

OldNewLine
1+## About this page
2+
3+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.
4+
5+## All systems
6+
7+### Default string type in Delphi mode
8+
9+- **Old behaviour**: {\$h-} used to be the default for Delphi mode. This means that "string" meant "shortstring", rather than "ansistring"
10+- **New behaviour**: the default for Delphi mode is now {\$h+} , so that "string" is now by default an alias for "ansistring" in that mode
11+- **Example**: self-evident
12+- **Reason**: {\$h+} is also on the default in Delphi
13+- **Effect**: if you use shortstring-specific code in {\$mode delphi} programs (such as accessing element 0, or accessing elements at an index \> length(string)), this code may no longer compile and/or run.
14+- **Remedy**: Adapt the code to work with ansistrings, or add {\$h-} *after* the {\$mode delphi} setting (or, when using the -Sd command line switch to select Delphi mode, add -Sh- as well)
15+
16+### Floating point constants
17+
18+- **Old behaviour**: all floating point constants were considered to be of the highest precision available on the target platform
19+- **New behaviour**: floating point constants are now considered to be of the lowest precision which doesn't cause data loss
20+- **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
21+- **Reason**: Delphi compatibility, avoid wrong precision-loss warnings when doing things like "singler:=single1*2.0"
22+- **Effect**: some expressions, in particular divisions of integer values by floating point constants, may now default to a lower precision than in the past.
23+- **Remedy**: if more precision is required than the default, typecast the floating point constant to a higher precision type, e.g. *extended(2.0)*. Alternatively, you can use the *-CF* command line option to change the default precision of all floating point constants in the compiled modules.
24+
25+### Pure assembler routines in Delphi mode
26+
27+- **Old behaviour**: a stack frame was always created, unless the procedure declaration was followed by *nostackframe*
28+- **New behaviour**: in Delphi mode, pure assembler functions no longer get a stack frame if all parameters are passed in registers, and if the @result/__result symbol is not referenced. On systems which require the stack to be aligned when performing a subroutine call (e.g., Darwin/i386), this stack alignment is still performed unless you use the "nostackframe" directive.
29+- **Example**: *function f(l1,l2,l3: longint): longint; asm end;* used to get a stack frame in on i386 in Delphi mode. Now it doesn't anymore.
30+- **Reason**: Delphi compatibility
31+- **Effect**: assembler routines which depended on getting a compiler-generated stack frame may no longer work in Delphi mode
32+- **Remedy**: do not use Delphi mode, turn the routine into an regular procedure/function with an embedded assembler block, rewrite the routine so it works without a stack frame, or explicitly reference the @result/__result symbol in the assembler code
33+
34+### System.Exitcode
35+
36+- **Old behaviour**: the Exitcode variable in the System unit was declared as word (16 bit) up to and including FPC 2.0.4
37+- **New behaviour**: System.Exitcode is now a longint
38+- **Reason**: OSes supporting 4 byte exit codes, Delphi compatibility
39+- **Effect**: assembler code accessing the *exitcode* variable may no longer work properly
40+- **Remedy**: adapt the assembler code so it uses the correct new size
41+
42+### RTLEventStartWait
43+
44+- **Old behaviour**: you had to call *RTLEventStartWait* before calling *RTLEventWaitFor*
45+- **New behaviour**: *RTLEventStartWait* has been removed from the RTL
46+- **Reason**: *RTLEventStartWait* only existed because the Unix implementation did not support persistent events. Now it does, so this routine is no longer necessary.
47+- **Effect**: code calling *RTLEventStartWait* will no longer compile
48+- **Remedy**: remove all calls to *RTLEventStartWait* from your code, they are no longer necessary
49+
50+### "In" operations
51+
52+- **Old behaviour**: an "in" operation always automatically converted the left operand to a byte-sized entity, just like Turbo Pascal
53+- **New behaviour**: the above is now only done in the TP compatibility mode. In other syntax modes, the full size of the left operand is kept (but sets with more than 256 elements are not yet fully supported)
54+- **Example**: in previous versions, *word_var:=256; writeln(word_var in \[0,1\]);* wrote TRUE if range checking was off, and generated a range check error if range checking was on. In 2.2.0, that behaviour is still the same in {\$mode tp}, but in other modes it will write FALSE and never generate a range check error.
55+- **Reason**: Delphi compatibility for {\$mode delphi}, and and also in FPC/OBJFPC/MACPAS modes because the new behaviour is more intuitive.
56+- **Effect**: non-TP mode code relying on *256 in \[0,1\]*-like behaviour will no longer work.
57+- **Remedy**: compile in TP mode, typecast the left operand of your in-statements to a byte, or change the logic of your program to work with the new behaviour.
58+
59+### MacPas OSType/FourCharCode
60+
61+- **Old behaviour**: strings could be implicitly converted to 32 bit integer values by the compiler in macpas mode (i.e., without a typecast)
62+- **New behaviour**: only constant strings of exactly 4 characters can be implicitly converted to 32 bit integers
63+- **Example**: *dword1:=stringvar;* and *dword1:='ab';* used to compile in macpas mode, but now this will give a compile time error. *dword1:='abcd';* will still work, however.
64+- **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.
65+- **Effect**: code using such constructs will no longer compile
66+- **Remedy**: 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. You can also access this function in other syntax modes by adding the unit "macpas" to your uses clause in those cases.
67+
68+### GPC mode
69+
70+- **New behaviour**: GPC mode has been disabled.
71+- **Reason**: it only disabled as many features as possible which has little to do with GPC compatibility. I.e., no compatibility with GPC has been abandoned, since the so-called GPC mode was not GPC-compatible in the first place.
72+- **Effect**: {\$mode gpc} and the command line switch *-mgpc* will no longer work.
73+- **Remedy**: use a different mode, FPC and MacPas modes are closest.
74+
75+### TFPHashtable renamed to TFPDataHashTable
76+
77+- **Old behaviour**: the contnrs unit of FPC 2.0.4 has a *TFPHashtable* class
78+- **New behaviour**: this type has been renamed to *TFPDataHashTable*
79+- **Reason**: There is now a base class called *TFPCustomHashTable*, on top of which several other hashtable implementations are based.
80+- **Remedy**: Use *TFPDataHashTable* (equivalent with the old *TFPHashTable*) if you want to store pointers, *TFPStringHashTable* if you want to store ansistrings, or *TFPObjectHashTable* if you want to store TObjects.
81+
82+## Unix
83+
84+### RTLEvent persistence
85+
86+- **Old behaviour**: calling *RTLEventSetEvent* before another thread was waiting caused the event to be lost
87+- **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)
88+- **Example**: see above
89+- **Reason**: compatibility with behaviour under Windows
90+- **Effect**: see above
91+- **Remedy**: for non-persistent events, use the *pthread_cond_signal/wait* and related routines directly
92+
93+## Non-i386
94+
95+### Floating point calculations
96+
97+- **Old behaviour**: all floating point calculations used to be performed using maximum precision
98+- **New behaviour**: floating point calculations involving only single precision values are now performed using single precision, etc.
99+- **Example**: *singler:=(single1/single2+single3)*single4* used to be calculated using maximum precision, and only be rounded back to single precision during the assignment. Now the intermediate calculations will also be done using single precision.
100+- **Reason**: speed (in particular single precision divisions are much faster than double precision ones), compatibility with gcc behaviour. Note that on i386, the x87 floating point unit is used by default, and that one does not support lower precision calculations. Therefore this behaviour will only be observed if -Cfsse2 or higher is used on i386 platforms (or if -Cfss2 is the default for said platform).
101+- **Effect & Remedy**: see "Floating point constants" section
102+
103+## 64 Bit systems
104+
105+### Vararray indices
106+
107+- **Old behaviour**: varrays (arrays stored in variants) used 64 bit indicies
108+- **New behaviour**: now they use 32 bit indicies only because this how it works on Win64
109+- **Reason**: the Variant functionality was originally based on a standard Windows type, so for compatibility with standard Windows routines and frameworks written in other languages, it has to be the same as that Windows type (and for portability, it should be the same on all platforms)
110+- **Effect**: variant arrays are now limited to maximally high(longint) items.
111+
112+## Previous release notes
113+
114+---
115+*From the Free Pascal wiki, page "User Changes 2.2.0", as it stood on 2019-12-08 after a change by Jonas, 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).*
116+Category: FPC User Changes by release
117+Category: Release Notes

Back to history