Sign in Join

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

Mailing lists / fpc-devel / 2002-05

Is these bags ?

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

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

Unknown author

I"ve a shared library using Free Pascal version 1.0.6 for Linux Red Hat 7.2 ( see shared_fp.pp below).
Two similar programs one writen in c (hello_c.c) the other in Free Pascal
(hello_fp.pp) use of this library.
I expect the results to be the same, but they are different. Why ?
Please answer if possible.

Best regards Lihachev Vladimir.

========= {file shared_fp.pp} ============
library shared_fp;
uses unit1;
exports
   myfunc;
end.

-------- {file unit1} -----------------

unit unit1;
interface
function myfunc: PChar; cdecl; export;
implementation
uses Linux, Crt;
function myfunc: PChar; cdecl; export;
var PCHour, PCMin, PCSec, PCMSec: Word;
begin
  GetTime(PCHour, PCMin, PCSec, PCMSec);
  writeln("PCHour=", PCHour);
  result:="Hello Word FPC";
end;
initialization
    writeln("initialization");
finalization
    writeln("finalization");
end.
=========================================
========={file hello_c.c} ===============
extern const char *myfunc();

int main(void)
{

  printf("%s\n", myfunc());
  return 0;

}

=========={ file hello_fp.pp} ===========
function myfunc: PChar; cdecl; external "libshared_fp.so";
begin
  writeln(myfunc);
end.

=========================================

Results of the program hello_c.c:
==================================
initialization
PCHour=9
Hello Word FPC
finalization
==================================

Results of the program hello_fp.pp:
==================================
PCHour=5
Hello Word FPC
==================================

__________
www.newmail.ru -- всегда что-то новое.

Reply by email