RFC: gfortran on Windows - handling of no console / pausing before end-of-program console destruction

Tobias Burnus burnus@net-b.de
Sun May 26 17:49:00 GMT 2013


On April 30, 2013 17:47, Tim Zeisloft wrote:
>> A message box which gives the error messages from the console or just an
>> "automated pause" to not close the console would certainly help those
>> users -
>>> and probably not harm anyone else.
>> I disagree with that. Although I see the value in a more "user friendly"
>> behavior on Windows w.r.t. console handling, one can argue whether it 
>> should
>> be handled by the compiler runtime or by the user program. And, more
>> importantly, the runtime "user friendly interface" might interfere 
>> with at
>> least two types of usage:
>>
>>    1. power users, who have existing setups (including scripting, 
>> automation,
>> etc.)
>>    2. large apps that have developped their own interface for this 
>> purpose
>>
>> Anything that is done in gfortran should be, in my opinion, at least
>> user-unselectable.
>
> It sounds like the consensus is that both these features could be 
> useful for mingw targets provided they be made selectable. I am 
> willing to implement this, though it might take a little while.
> Would switches named --error-messagebox/--no-error-messagebox and 
> --pause-on-exit/--no-pause-on-exit suffice?

Sorry for the belated reply - I was busy with other things and kind of 
forgot about this item. Additionally, I was hoping to see some reply 
from others.


The "no console available" implies that one passes this flag when one 
compiles the Fortran main program, cf. 
http://gcc.gnu.org/onlinedocs/gfortran/Non_002dFortran-Main-Program.html 
- That flag only makes sense with Windows as there the ABI function is 
automatically available and code is started without console. (For Unix, 
a message box is not practical - already for dependency reasons. I don't 
know whether the issue can occur on OSX/Darwin and whether library 
dependency is an issue.) It's not clear to me whether the option should 
be printed at startup or when doing I/O to standard out/in 
(OUTPUT:_UNIT, INPUT_UNIT). The former is simpler and faster, but has 
"false positive". The latter is slower but hasn't. I think it should be 
silently accepted by the compiler on non-Windows systems, even if it is 
in the library only available for MinGW, MinGW-w64 and presumably 
Cygwin(64).


For pause on exit, it is not clear me whether that always triggers or 
only when the console would otherwise close. If the latter, I wonder who 
that's detectable from within the run-time library. (If one has to 
modify MinGW and MinGW-w64, it would be more difficult - as one has also 
get code into that library.) At least for a "only pause when the console 
would otherwise close" feature, it would be Windows only. However, one 
could implement it as always pause before exit on other systems; the 
latter might be not often useful, but sometimes it could. Thus, I think 
this option should be generally available - even if it has slightly 
different run-time behaviour.


Regarding the name: "-fpause-on-exit" (= "--pause-on-exit") seems to be 
fine. But "-ferror-messagebox" I find a bit misleading - but I don't 
have a great suggestion. Maybe -fmsgbox-if-no-console?

For the implementation: On the compiler side, it has to be added to 
lang.opt (options.c, gfortran.h) and trans-decl.c's 
create_main_function. It has to be documented in gfortran's invoke.texi 
and gfortran.texi's "Non-Fortran Main Program".

Tobias



More information about the Fortran mailing list