Forum > General

[SOLVED] FreePascal version information.

(1/3) > >>

I just found some old code of mine I wrote as an internal test for an accepted patch to system that I wrote (OpaqueData):
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$mode objfpc}var  sfpcv : TOpaqueData;external name '__fpc_ident';begin  Writeln(PChar(@sfpcv));end. 
Is this always guaranteed to work? Then I can add that test to the wiki or even create a function for it.
What it does that it retrieves the compiler version, compiler date and platform from the binary for which it is compiled.
( You can do this with any section, but this one seems very useful )

Probably only a compiler dev can answer this. I tested on my usual platforms.

Code search results in this:
so it's probably still relevant.


--- Quote from: Red_prig on March 24, 2023, 12:16:00 pm ---Code search results in this:
so it's probably still relevant.

--- End quote ---
That info is known to me and how I could write it.
I merely want to know if it is safe in all or most platforms.

Otherwise it can be a false impression.

But thanks for the contribution: I think... it is still relevant too. That's why I ask.
Except for the macro's there is not really a PUBLISHED efficient way to detect with what compiler version a FPC/Lazarus version is compiled.

A quick look shows that this is always initialized in InsertMemorySizes, but in the 8086 and jvm platforms the function code is overridden, so it looks like except for these 2 cases.

AFAIK the recommended way is to use {$I xxx} for that, see
This is guaranteed to work at all times.



[0] Message Index

[#] Next page

Go to full version