I just want to note that FPC 3.2.2 and 3.2.4 also have bugs, just like FPC[main]
And it's still a big question where there are more of them
Yes, my post above is about v3.2.2.
I have little to no idea what the situation is with v3.2.4 and FPC main. I'd like to see (really, just hoping) some of those bugs addressed in v3.2.4.
without running into FPC bugs
Could you give a small example, please?
Perhaps there are workarounds
Sure.
The first example is when defining bit fields in a record.
In 32 bit, if the field has more than 32 bits then it simply cannot be defined.
In 64 bit, there are a number of cases where the definition ends up being wrong. In some cases, if the number of bits add up to 64, the compiler will not accept the definition. In other cases, it will accept the definition but, either the offset of the next field (following the bit field) is incorrect and/or the total size of the record is incorrect. This requires a number of acrobatics to get the definition to be somewhat usable, i.e, the correct size and correct field offsets.
I recently reported this bug here in the forums and in the bug tracker.
Another case, also involving bit fields is when the C definition uses arithmetic expression to specify the number of bits a particular field uses. Since FPC uses ranges to specify the number of bits, using expressions is not possible. In this case, it takes a manual conversion to set the sizes but, the definition, unlike the expression, isn't scaleable. Fortunately, there are very few definition that use bit field expressions.
Another problem and that one is common enough to be a real problem is when the record/structure needs to be aligned on a boundary greater than 8. The same problem if any one of the fields in the record/structure needs to be aligned on a boundary greater than 8. The field alignment requires manually calculating the padding and declaring the padding fields. Must not forget that the alignment of those fields also affects the total size of the structure, IOW, there is a "trailing" alignment field required and that one is far from obvious. Aligning the record at a boundary greater than 8 is simply beyond FPC's abilities. Therefore that one requires the code to _create_ blocks of memory that are aligned as required.
Those are just some examples I've recently ran into. They are far from the only problems I've run into when porting the Windows API from C to FPC.