Recent

Author Topic: [solved] How can the compile-date be used  (Read 1056 times)

Joanna

  • Hero Member
  • *****
  • Posts: 868
[solved] How can the compile-date be used
« on: May 14, 2024, 02:32:31 pm »
Hi everyone elmar69 asked this in chat. Does anyone know the answer? I’m curious too.

 How can the compile-date be used/displayed from compiled code?
« Last Edit: May 14, 2024, 11:00:45 pm by Joanna »
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

dseligo

  • Hero Member
  • *****
  • Posts: 1286

cdbc

  • Hero Member
  • *****
  • Posts: 1350
    • http://www.cdbc.dk
Re: How can the compile-date be used
« Reply #2 on: May 14, 2024, 05:54:12 pm »
Hi
I use it like this:
Code: Pascal  [Select][+][-]
  1. if S = 'Start' then
  2.   LogSvc.LogLn('<- gui='+memGuiVersion+' - fpc='+{$i %fpcversion%}+' @ '+{$i %date%}+' '+{$i %time%}+' - engine='+engver+' - debug ->');
Where "engver" & "memGuiVersion" are my own variables...
HTH
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

Thaddy

  • Hero Member
  • *****
  • Posts: 15192
  • Censorship about opinions does not belong here.
Re: How can the compile-date be used
« Reply #3 on: May 14, 2024, 06:50:37 pm »
Benny,
You can also use my version trick for %compilerversion%.
If you are a trunk user, you can determine the patch version.
I am referring to this:
Code: Pascal  [Select][+][-]
  1. var
  2.   fpcversion:array[0..255] of char; external name '__fpc_ident';
  3. begin
  4.   writeln(fpcversion);
  5. end.
Which prints the real compiler version.
Code: Bash  [Select][+][-]
  1. $ /mnt/d/version
  2. FPC 3.3.1-15668-ge657d6a07d [2024/05/05] for x86_64 - Linux
This is only helpful for trunk/main users, I guess. But you always get the date that the compiler is compiled. (Not necessary the patch version)
« Last Edit: May 14, 2024, 06:58:27 pm by Thaddy »
Of course the national anthem of the U.S.A. was written by Jimi Hendrix, didn't you know that?

cdbc

  • Hero Member
  • *****
  • Posts: 1350
    • http://www.cdbc.dk
Re: How can the compile-date be used
« Reply #4 on: May 14, 2024, 07:50:50 pm »
Hi Thaddy
Cool, thanks, didn't know 'bout this one  8-)
Will come in very handy, as I develop all of my own work in trunk and there, it's nice to know which and when the compiler is from, especially in lieu of the past couple of months' hickups  :D
I only use my 3.2.2 compiler for examples etc. for this forum...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

PascalDragon

  • Hero Member
  • *****
  • Posts: 5585
  • Compiler Developer
Re: How can the compile-date be used
« Reply #5 on: May 14, 2024, 10:20:20 pm »
You can also use my version trick for %compilerversion%.
If you are a trunk user, you can determine the patch version.
I am referring to this:
Code: Pascal  [Select][+][-]
  1. var
  2.   fpcversion:array[0..255] of char; external name '__fpc_ident';
  3. begin
  4.   writeln(fpcversion);
  5. end.

The existance of this symbol is not documented and thus must be considered an implementation detail (as I had already told you here). So if you have to mention this, then please also mention that it isn't documented and thus isn't official and thus anyone uses it at their own risk.

(Also this symbol already exists for seven years and thus is also part of the 3.2.x series)

Thaddy

  • Hero Member
  • *****
  • Posts: 15192
  • Censorship about opinions does not belong here.
Re: How can the compile-date be used
« Reply #6 on: May 14, 2024, 10:33:20 pm »
Point taken. It is just one of the "Just because I can"....
Of course the national anthem of the U.S.A. was written by Jimi Hendrix, didn't you know that?

Joanna

  • Hero Member
  • *****
  • Posts: 868
Re: How can the compile-date be used
« Reply #7 on: May 14, 2024, 11:00:07 pm »
Thanks for the answers, I figured it would be something related to compiler directives
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

 

TinyPortal © 2005-2018