Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide compiler version and compiler options via stdlib_version #582

Open
awvwgk opened this issue Nov 27, 2021 · 1 comment
Open

Provide compiler version and compiler options via stdlib_version #582

awvwgk opened this issue Nov 27, 2021 · 1 comment

Comments

@awvwgk
Copy link
Member

awvwgk commented Nov 27, 2021

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)

@gareth-nx
Copy link
Contributor

Agree this would be nice to have, when a sufficient number of compilers are happy with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants