Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-12

Re: Error: Can't declare procedure as EXTERNAL

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author
to Den Jean: the new FPC CVS release of 29/11 forbids delphi / kylix type of library use eg…
Den Jean wrote 20 lines
Hi, the new FPC CVS release of 29/11 forbids delphi / kylix type of library use eg -------------------------------------------------------------------------------------------------------------- interface function QObjectList_create: QObjectListH; cdecl; overload; function QObjectList_create(list: QObjectListH): QObjectListH; cdecl; overload; implementation function QObjectList_create(list: QObjectListH): QObjectListH; cdecl; external QtShareName name QtNamePrefix + 'QObjectList_create2'; function QObjectList_create: QObjectListH; cdecl; external QtShareName name QtNamePrefix + 'QObjectList_create'; -------------------------------------------------------------------------------------------------------------- is forbidden now and generates a "Error: Can't declare procedure as EXTERNAL" when compiling.

This is correct.

Show quoted text 6 lines
Apparently the external directive has to be moved to the INTERFACE section. I do not know why this has changed (perhaps a very good reason), but to me it seems not so good: 1) This is not Delphi/Kylix compatible (just try to compile Qt.pas)

This is known, but is unfortunately unavoidable. Delphi/Kylix uses an internal linker and can therefore solve this problem. FPC has to use an external linker, and therefore the assembler label must be fixed already in the interface section. (it has to do with the case when 2 units are using each other)

2) This breaks a lot of existing code, especially bindings ( I will need to move 3283 external directives in my qte binding)

This is known, but can't be helped.

And most importantly: 3) This way the interface gets cluttered with implementation details like "name QtNamePrefix + 'QObjectList_create2'"

Once more, this is known, but cannot yet be solved. Only when FPC has an internal linker, this problem can be solved.

That it worked in the past is pure luck. (well, almost)

Michael.

Reply by email

Peter Vreman
to Unknown author
> 2) This breaks a lot of existing code, especially bindings ( I will > need to move 3283 external directives in my qte binding) This is known, but can't be helped.

Simple solution: Put them in an include file. Also the interface declarations for kylix. For FPC only use the include file with the externals in the interface and for Kylix use both include files.

Reply by email

Unknown author
to Peter Vreman
Peter Vreman wrote 8 lines
>> 2) This breaks a lot of existing code, especially bindings ( I will >> need to move 3283 external directives in my qte binding) > > This is known, but can't be helped. Simple solution: Put them in an include file. Also the interface declarations for kylix. For FPC only use the include file with the externals in the interface and for Kylix use both include files.

If you have it in the interface anyway, there is no need to have both files ?

Michael.

Reply by email

Den Jean

Hi,

the new FPC CVS release of 29/11 forbids
delphi / kylix type of library use

eg

--------------------------------------------------------------------------------------------------------------
interface
function QObjectList_create: QObjectListH; cdecl; overload;
function QObjectList_create(list: QObjectListH): QObjectListH; cdecl; overload;
implementation
function QObjectList_create(list: QObjectListH): QObjectListH; cdecl; external QtShareName name QtNamePrefix + 'QObjectList_create2';
function QObjectList_create: QObjectListH; cdecl; external QtShareName name QtNamePrefix + 'QObjectList_create';
--------------------------------------------------------------------------------------------------------------

is forbidden now and generates a "Error: Can't declare procedure as EXTERNAL" when compiling.

Apparently the external directive has to be moved to the INTERFACE section. I do not know why this has changed (perhaps a very good reason), but to me it seems not so good:

1) This is not Delphi/Kylix compatible (just try to compile Qt.pas)

2) This breaks a lot of existing code, especially bindings ( I will need to move 3283 external directives in my qte binding)

And most importantly:
3) This way the interface gets cluttered with implementation details like "name QtNamePrefix + 'QObjectList_create2'"

kind regards,

Den Jean

Reply by email

Florian Klaempfl
to Unknown author: This is correct. This is known, but is unfortunately unavoidable. Delphi/Kylix uses an…
Show quoted text 8 lines
> 1) This is not Delphi/Kylix compatible (just try to compile Qt.pas) This is known, but is unfortunately unavoidable. Delphi/Kylix uses an internal linker and can therefore solve this problem. FPC has to use an external linker, and therefore the assembler label must be fixed already in the interface section. (it has to do with the case when 2 units are using each other)

Can't we allow it with a warning? Only under rare circumstances the late external cause problems afaik.

Show quoted text 6 lines
> 2) This breaks a lot of existing code, especially bindings ( I will need to move 3283 external directives in my qte binding) This is known, but can't be helped.

Reply by email