J. David Bryan wrote:
I am working with gpc-20030507 (with gcc-3.2.3, i486-pc-mingw), and I have noted two changes in compiler behavior from gpc-20021128. I don't know whether these are bugs or intentionally revised features.
The latter.
- The "addr" function no longer observes the --no-typed-address command
line switch. The GPC manual says:
--no-typed-address Make the result of the address operator an untyped pointer (same as {$T-}).
...and:
Addr returns the address of its argument. It is equivalent to the address operator....
...so I would expect that "addr" and "@" would behave the same. They did under gpc-20021128. However, this now fails to compile with "--no-typed-address":
program addrtest;
var i : integer; a, b : ^ byte;
begin a := @ i; { ok if --no-typed-address, fails otherwise } b := addr (i); { fails always, "incompatible pointer type" } end.
In BP, `Addr' is always untyped. I consider this a historical bug (because in older BP versions also `@' was untyped). So GPC does this only with `--borland-pascal'. Otherwise it's always typed (which I consides more sane -- if you want to convert the pointer, you can always use an explicit cast, rather than hiding the fact).
Only `@' now depends on `--typed-address', in GPC just like in BP.
I'll adjust the documentation.
- Using an interface-only module to declare routines in an exernal library
no longer works. The importing program declares an external to "_init_<module-name>", but no entry point is provided by the module, so the program won't link. The GPC manual says:
To use a function written in another language, you need to provide an external declaration for it - either in the program, or in the interface part of a unit, or an interface module.
Also here, I'll change the documentation. EP is clear on that an interface module requires an implementation.
Solution: Use a non-interface module (drop `interface' and add `end;' before `end.').
They both compile but fail during linking (presuming a library is supplied that declares "_Proc" as an entry point) with an undefined reference to "init_Ifmod". This worked in gpc-20021128 because "iftest.o" did not reference the "_init_Ifmod" entry point.
Which was a bug that caused some serious problems (e.g., strings in interface modules not being initialized).
Frank