Rob,
On 24/05/2014 14:29, Rob Arthan wrote:
What exactly do you mean by a console application?
I mean the kind of thing that Visual Studio creates if you select
“Win32 Console Application” when you create a new C++ project. I.e.,
a program with the standard C interface to the operating system,
i.e., an entry point called main.
This isn’t much of a problem for me, but what you are offering is
rather inconvenient for anyone who wants to write ML programs that
present the kind of interface that Windows command line programs like
“sort" offer (with cmd.exe and the C runtime providing interactive
input and output from a console window and redirection of standard
input and output to files). Such things can be written portably using
standard C or standard C++ and, it would be nice to be able to code
similar things in ML without needing a wrapper to call them on
Windows.
I see. I have to say that I'm really surprised that anyone would
actually want to build a console application; I'd always regarded it as
a legacy from DOS. It's quite easy, though, to do it if you want to.
Console applications just have the "console" subsystem set in the EXE
header rather than "windows" so to build a console application you just
need the /SUBSYSTEM:CONSOLE option to the linker (-mconsole with GCC).
By default, setting /SUBSYSTEM:CONSOLE also changes the entry point but
since poly uses the WinMain entry point you have to change it back again
with a /ENTRY:WinMainCRTStartup option. To build a console application
under Mingw/Msys just change -mwindows to -mconsole.
There were a couple of issues when I tried this to build poly: control-C
was not handled properly and the console stream wasn't recognised as
interactive. I've fixed these in SVN trunk.
This is for the scenario where I write (in some other language) a GUI
that is going to start my ML program and interact with it via files
or pipes or suchlike. Is that right?
Correct.
The only circumstance where the present system may not work
satisfactorily is if you have written a GUI application in ML
itself, for instance the mlEdit example in
mlsource/extra/Win/Examples.
How do you compile the code in that directory? It doesn’t seem to
contain the source file for mlEdit that the documentation for the
Windows interface refers to.
The code for mlEdit is in mlEdit.sml. It's definitely there in every
polyml directory I've looked at. You need to build the Windows GUI code
first:
PolyML.make "mlsource/extra/Win";
and then
use "mlsource/extra/Win/Examples/mlEdit";
That might be an option, but it seems like quite an overhead to have
to include something that provides vast amounts of functionality to
emulate UNIX that I just don’t need and is a potential source of
problems. So I was trying to explore the options for having libpolyml
use standard C++ libraries (and not the Windows GUI libraries)
without emulating UNIX.
Agreed. I was just trying to suggest an easy way to get a console-like
window.
I am also thinking about the possibility of packaging an ML program
as a Windows service (by providing my own libpolymain with entry
points ServiceMain etc.) and thought that would be incompatible with
the Windows GUI stuff, but maybe it will work with libpolyml compiled
as it is presently or maybe it just doesn’t make sense. I will have
to do some experiments.
You could certainly do that if it made sense for your application.
Services are essentially the equivalent of Unix daemons.
Regards,
David
_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml