Forum > General
[SOLVED] FreePascal version information.
Thaddy:
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.
Red_prig:
Code search results in this:
https://gitlab.com/freepascal.org/fpc/source/-/blob/main/compiler/ngenutil.pas
so it's probably still relevant.
Thaddy:
--- Quote from: Red_prig on March 24, 2023, 12:16:00 pm ---Code search results in this:
https://gitlab.com/freepascal.org/fpc/source/-/blob/main/compiler/ngenutil.pas
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.
Red_prig:
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.
Bart:
AFAIK the recommended way is to use {$I xxx} for that, see https://www.freepascal.org/docs-html/prog/progsu41.html#x48-470001.2.41.
This is guaranteed to work at all times.
Bart
Navigation
[0] Message Index
[#] Next page