I've produced some Pascal which is called from C. The Pascal program looks like this:
program myprog;
{$gpc-main=Dummy}
myfunc (parameters.. .) : integer; asmname 'name';
{$include "myfile.pas"}
begin end.
The function myfunc is given in the file "myfile.pas".
To suit the new compiler 20030323 I changed the declaration above to
myfunc (parameters.. .) : integer; attribute (name = 'name'); external;
The compiler now objects to the re-declaration of myfunc. How can I get round this without editing myfile.pas (which is used by a number of other programs, so I don't want to alter it)?
Andrew.
------------------------------------------------------------------- This e-mail and any attachments may contain confidential and/or privileged material; it is for the intended addressee(s) only. If you are not a named addressee, you must not use, retain or disclose such information.
NPL Management Ltd cannot guarantee that the e-mail or any attachments are free from viruses.
NPL Management Ltd. Registered in England and Wales. No: 2937881 Registered Office: Teddington, Middlesex, United Kingdom TW11 0LW. -------------------------------------------------------------------
Andrew Gregory a écrit:
I've produced some Pascal which is called from C. The Pascal program looks like this:
program myprog;
{$gpc-main=Dummy}
myfunc (parameters.. .) : integer; asmname 'name';
{$include "myfile.pas"}
begin end.
The function myfunc is given in the file "myfile.pas".
To suit the new compiler 20030323 I changed the declaration above to
myfunc (parameters.. .) : integer; attribute (name = 'name'); external;
The compiler now objects to the re-declaration of myfunc. How can I get round this without editing myfile.pas (which is used by a number of other programs, so I don't want to alter it)?
Just add the standard keyword "forward".
function myfunc (parameters.. .) : integer; attribute (name = 'name'); external; forward;
In fact the old working was standard deviant, it should have not worked.
Maurice
Maurice Lombardi wrote:
Andrew Gregory a écrit:
I've produced some Pascal which is called from C. The Pascal program looks like this:
program myprog;
{$gpc-main=Dummy}
myfunc (parameters.. .) : integer; asmname 'name';
{$include "myfile.pas"}
begin end.
The function myfunc is given in the file "myfile.pas".
To suit the new compiler 20030323 I changed the declaration above to
myfunc (parameters.. .) : integer; attribute (name = 'name'); external;
The compiler now objects to the re-declaration of myfunc. How can I get round this without editing myfile.pas (which is used by a number of other programs, so I don't want to alter it)?
Just add the standard keyword "forward".
Or just omit the first declaration (unless you really need to call it before its definition). Unlike in C, there's no need to "prototype" each routine.
function myfunc (parameters.. .) : integer; attribute (name = 'name'); external; forward;
Without `external'.
Frank