Sign in Join

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

Mailing lists / fpc-pascal / 2011-01

exports VS export

7 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Alex Shishkin

what is the difference between "export" proedure/function modifier and listing this routine in "exports" section?
On win32 with fpc 2.4.3 i've got a crash on program start then using export modifier in statically linked dll.

Reply by email

Jonas Maebe
to Alex Shishkin
Alex Shishkin wrote
what is the difference between "export" proedure/function modifier and listing this routine in "exports" section?

In theory, they should mean the same.

In practice, FPC currently only actually exports routines that are in the "exports" section of a library, or that are marked as export *and* that have been (re)compiled during the current compilation run (i.e., that were not compiled previous compilation and simply loaded from a .ppu file). See http://bugs.freepascal.org/view.php?id=16070

Jonas

Reply by email

Alex Shishkin
to Jonas Maebe

18.01.2011 15:34, Jonas Maebe пишет:

Show quoted text 17 lines
On 18 Jan 2011, at 13:27, Alex Shishkin wrote: > what is the difference between "export" proedure/function modifier > and listing this routine in "exports" section? In theory, they should mean the same. In practice, FPC currently only actually exports routines that are in the "exports" section of a library, or that are marked as export *and* that have been (re)compiled during the current compilation run (i.e., that were not compiled previous compilation and simply loaded from a .ppu file). See http://bugs.freepascal.org/view.php?id=16070 Jonas

Following code crashes if disable define use_export_section.

library lib;
{$mode objfpc}{$H+}

uses
Classes
{ you can add units after this };

{$R *.res}
{$define use_export_section}
procedure PrintHello; {$ifndef use_export_section} export; {$endif}
begin
WriteLn('Hello world');
end;
{$ifdef use_export_section}
exports PrintHello;
{$endif}
begin
end.

Reply by email

Jonas Maebe
to Alex Shishkin
Alex Shishkin wrote
Following code crashes if disable define use_export_section.

What do you mean by "crashes"? A segmentation fault? If so, where exactly does it crash? And how do you import that routine in the program and call it? Currently, the "export" modifier apparently does not add an alias for the unmangled name, so I'm not sure how you are even getting things linked successfully.

Jonas

Reply by email

Alex Shishkin
to Jonas Maebe

18.01.2011 22:28, Jonas Maebe пишет:

What do you mean by "crashes"? A segmentation fault? If so, where exactly does it crash? And how do you import that routine in the program and call it? Currently, the "export" modifier apparently does not add an alias for the unmangled name, so I'm not sure how you are even getting things linked successfully.

Attempt to run with static linking crashes debugger. Dynamic linking simply failed. So I ask what does modifier "export" actually do?

Reply by email

Jonas Maebe
to Alex Shishkin
Alex Shishkin wrote
18.01.2011 22:28, Jonas Maebe пишет: > What do you mean by "crashes"? A segmentation fault? If so, where exactly does it crash? And how do you import that routine in the program and call it? Currently, the "export" modifier apparently does not add an alias for the unmangled name, so I'm not sure how you are even getting things linked successfully. > Attempt to run with static linking crashes debugger.

You posted the source to a library. It is not possible to run a library. So again: what is the program that you wrote that imports that routine and how did you import that routine in that program?

Additionally, afaik FPC does not currently support creating statically linkable libraries. So how did you statically link a compilation unit that starts with the "library" keyword into a program?

Dynamic linking simply failed

What is the error that you got?

So I ask what does modifier "export" actually do?

a) it makes the routine's symbol public, so that it can be referenced from other object files b) for the OS/2 and EMX targets, it also adds the routine to the "deffile" (I don't know the details about that)

Jonas

Reply by email

Alex Shishkin
to Jonas Maebe

18.01.2011 23:08, Jonas Maebe пишет:

Show quoted text 9 lines
On 18 Jan 2011, at 20:46, Alex Shishkin wrote: > 18.01.2011 22:28, Jonas Maebe пишет: >> What do you mean by "crashes"? A segmentation fault? If so, where exactly does it crash? And how do you import that routine in the program and call it? Currently, the "export" modifier apparently does not add an alias for the unmangled name, so I'm not sure how you are even getting things linked successfully. >> > Attempt to run with static linking crashes debugger. You posted the source to a library. It is not possible to run a library. So again: what is the program that you wrote that imports that routine and how did you import that routine in that program? Additionally, afaik FPC does not currently support creating statically linkable libraries. So how did you statically link a compilation unit that starts with the "library" keyword into a program?

I meant using "external 'lib.dll' "

> Dynamic linking simply failed What is the error that you got?

"procedure could not be found"

> So I ask what does modifier "export" actually do? a) it makes the routine's symbol public, so that it can be referenced from other object files b) for the OS/2 and EMX targets, it also adds the routine to the "deffile" (I don't know the details about that)

clear thanks.

Alex.

Reply by email