Sign in Join

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

Mailing lists / fpc-pascal / 2015-10

undocumented 'library' hint directive

7 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

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

Graeme Geldenhuys

Hi,

Based on the latest FPC Language Reference documentation, there is no "library" hint directive (like Delphi & Kylix has)...

http://www.freepascal.org/docs-html/ref/refse5.html#x17-160001.5

Or Section 1.5 on page 16 of the PDF.

Yet the following example program compiles without error using FPC 2.6.4. I gather this is an omission in the documentation?

Second question, what does the "library" hint directive mean or do?

=========================================
program test;
{$mode objfpc}{$h+}
uses
  SysUtils, Classes;
var
  VersionNumber: Real library;
begin
  VersionNumber := 1.234;
  writeln(VersionNumber);
end.

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

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 13 lines
Hi, Based on the latest FPC Language Reference documentation, there is no "library" hint directive (like Delphi & Kylix has)... http://www.freepascal.org/docs-html/ref/refse5.html#x17-160001.5 Or Section 1.5 on page 16 of the PDF. Yet the following example program compiles without error using FPC 2.6.4. I gather this is an omission in the documentation? Second question, what does the "library" hint directive mean or do?

Good question. It's the first time I heard of the 'library' directive.

Michael.

Reply by email

Marco van de Voort
to Graeme Geldenhuys: Based on the latest FPC Language Reference documentation, there is no "library" hint…

In our previous episode, Graeme Geldenhuys said:

Show quoted text 7 lines
Based on the latest FPC Language Reference documentation, there is no "library" hint directive (like Delphi & Kylix has)... Yet the following example program compiles without error using FPC 2.6.4. I gather this is an omission in the documentation? Second question, what does the "library" hint directive mean or do?

http://docwiki.embarcadero.com/RADStudio/Seattle/en/Declarations_and_Statements

A lot of the later ones were added in one go, not all might be implemented. Seems it is only meant to flag functions as potentially os dependent, similar to platform.

Another such one is experimental.

Quote from above link:

Use platform to mark items that are specific to a particular operating environment (such as Windows), deprecated to indicate that an item is obsolete or supported only for backward compatibility, and library to flag dependencies on a particular library or component framework.

(MvdV: read: VCL vs CLX)

The Delphi compiler also recognizes the hinting directive experimental. You can use this directive to designate units that are in an unstable development state. The compiler will emit a warning when it builds an application that uses the unit.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt: Good question. It's the first time I heard of the 'library' directive. Michael.
Michael Van Canneyt wrote
Good question. It's the first time I heard of the 'library' directive.

The Delphi documentation is very vague too.

http://docwiki.embarcadero.com/RADStudio/Seattle/en/Declarations_and_Statements#Hinting_Directives

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Graeme Geldenhuys
to Marco van de Voort: In our previous episode, Graeme Geldenhuys said:…
Marco van de Voort wrote

To follow on from your quotes....

"The platform and library directives do not specify which platform or library. If your goal is writing platform-independent code, you do not need to know which platform a symbol is specific to; it is sufficient that the symbol be marked as specific to some platform to let you know it may cause problems for your goal of portability."

I guess with the above description IFDEF's will most likely be the better option in real-world code.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Marco van de Voort
to Graeme Geldenhuys

In our previous episode, Graeme Geldenhuys said:

Show quoted text 6 lines
> http://docwiki.embarcadero.com/RADStudio/Seattle/en/Declarations_and_Statements To follow on from your quotes.... I guess with the above description IFDEF's will most likely be the better option in real-world code.

Those were always more to aid with the VCL->CLX transition or cohabitation.

Those share many common method names, but directives like this allowed to ban/flag some of them (like gethandle, windowhandle etc), making it easier to upgrade/prepare vcl codebases to CLX.

Deprecated and platform are a bit more generic.

Experimental is mainly to make absolutely clear that not anything published is definitive. IMHO should be used more often.

Reply by email