Are you sure that -g is the trigger? It may very well be that you need to
make sure that the optimiser does not eliminate the variable that holds the
identification. That is why I write the first character of these strings,
to make sure that the variables are retained. That could be achieved in all
manner of ways to fool the optimiser. Note that with -O2 and the program I
posted I still get the strings.

Regards,

Arjen

Op wo 1 jun. 2022 om 13:36 schreef Arjen Markus <arjen.markus...@gmail.com>:

> Hm, I ran it without any options - would that be equivalent to -g then? A
> rather awkward workaround might be to compile one source file containing
> this code with -g, but that is pushing things to the limit.
>
> Regards,
>
> Arjen
>
> Op wo 1 jun. 2022 om 12:16 schreef Kay Diederichs <
> kay.diederi...@uni-konstanz.de>:
>
>> I tried your suggestion below, but it does not store the options unless
>> the -g option is used.
>>
>> If -g is used, the executable _always_ has version and option info (no
>> extra code invoking compiler_version() and compiler_options() is
>> needed). Just use strings <binary> | grep GNU .
>> If -g is not used, no option info is in the executable.
>>
>> Best wishes,
>> Kay
>>
>> On 01.06.22 12:00, Arjen Markus wrote:
>> > staticv.f90 --
>> > !     Static information about the compiler? Not via parameters
>> > !
>> > program staticv
>> >      use iso_fortran_env
>> >
>> >      implicit none
>> >      character(len=200) :: c, d
>> >
>> >      c = compiler_version()
>> >      d = compiler_options()
>> >      write(*,*) c(1:1), d(1:)1
>> > end program staticv
>> >
>>
>> --
>> Kay Diederichs                http://strucbio.biologie.uni-konstanz.de
>> email: kay.diederi...@uni-konstanz.de             Tel +49 7531 88 4049
>> Fachbereich Biologie, Universität Konstanz, Box M647, D-78457 Konstanz
>>
>> This e-mail is digitally signed. If your e-mail client does not have the
>> necessary capabilities, just ignore the attached signature "smime.p7s".
>>
>

Reply via email to