Skip to content

Provide compiler version and compiler options via stdlib_version #582

Open
@awvwgk

Description

@awvwgk

Would it be useful for this module to also provide compile-time constants of compiler version and options used to build it?

module m
  use iso_fortran_env, only: compiler_version, compiler_options
  character(*), parameter :: stdlib_compiler_version = compiler_version()
  character(*), parameter :: stdlib_compiler_options = compiler_options()
end module m

program p
  use m
  print *, stdlib_compiler_version
  print *, stdlib_compiler_options
end

It works nicely with GFortran, but ifort 2021.3.0 doesn't seem to allow these intrinsic in constant expressions:

$ ifort test.f90 
test.f90(3): error #6263: This intrinsic function is invalid in constant expressions.   [COMPILER_VERSION]
  character(*), parameter :: stdlib_compiler_version = compiler_version()
-------------------------------------------------------^
test.f90(4): error #6263: This intrinsic function is invalid in constant expressions.   [COMPILER_OPTIONS]
  character(*), parameter :: stdlib_compiler_options = compiler_options()
-------------------------------------------------------^
test.f90(8): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [M]
  use m
------^
compilation aborted for test.f90 (code 1)

which I think is incorrect. Anyhow, just an idea, something we could tackle in another PR.

Originally posted by @milancurcic in #579 (review)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions