Logo

Programming-Idioms

  • Lisp
  • Go
  • JS
  • Pascal
  • D

Idiom #210 Compiler version and options

Assign, at runtime, the compiler version and the options the program was compiled with to variables version and options, respectively, and print them. For interpreted languages, substitute the version of the interpreter.

Example output:

GCC version 10.0.0 20190914 (experimental)
-mtune=generic -march=x86-64

const { version } = process;
console.log(version);

This doesn't work in a browser.
import "runtime"
version := runtime.Version()
writeln({$I %fpcversion%});

Obviously FreePascal only.
Compiler options are not available through a single variable.
use iso_fortran_env
  character(len=:), allocatable :: version, options
  version = compiler_version()
  options = compiler_options()
  print *,version
  print *,options

New implementation...
< >
tkoenig