lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Mike.
 I compiled lua 5.0 (and 0.1 and 0.2) with many compilers under windows: mingw, lcc, VC++ (the free command line version), Borland (again the free version) and OpenWatcom. Also tried multiple Windows versions (98, 2K, XP).

For 5.1 work I only tested mingw so far, I'll try the others as soon as I can. I've never tried Wine, though.

The problem only appears to me using lua (the stand alone interpreter) in interactive mode: if compiled with mingw, the prompt simply does not show up and errors do the same. I noticed it is a consistent behaviour of mingw-compiled executables: output to stderr is deferred while output to stdout is immediate.

So, you are right, it's a matter of compiler libraries, all other compilers create executables that behave as expected.

I guess it won't arm adding the fflush(stderr) anyway but to play safe I enclosed in an #ifdef.

I'll do more extensive test and I'll report back the results.

Remo


> Hi,
> 
> Remo Dentato wrote:
> > Compiling the standalone lua interpreter with mingw also shows 
> an issue
> > with printing to stderr. It seems that stderr is not flushed 
> immediatly
> > (as it happens with other Windows compilers, lcc for example).
> 
> IMHO this cannot be a problem of the compiler. It's more
> a problem with the libraries or the execution environment.
> 
> > I personally added
> >
> >   #ifdef __MINGW32__
> >     fflush(stderr);
> >   #endif
> >
> > in lua.c at the end of both l_message() and print_usage().
> 
> Well, I have no problem getting the output from lua -h.
> Did you run the compiled EXE under Wine or on 'real' Windows?
> 
> Because I've encountered a different variation: print()
> doesn't work with my MingW compiled executable when I run
> it under Wine in non-interactive mode.
> 
> I.e. lua -e 'print("foo")' gives no output. Typing the same
> command at the Lua prompt works fine. OTOH io.write() works
> in both modes.
> 
> If I replace the fputs() in lbaselib.c with fwrite() I can get
> print() to work. Well ...
> 
> But when I run the same binary on Win98 everything works
> as expected.
> 
> That's why I suspected a problem with my Wine installation.
> I didn't bother to track it down until now. But since you
> seem to have a similar problem ...
> 
> I've searched the MinGW and Wine archives to no avail. There
> are some vague messages that hint at problems with flushing
> stdout and stderr for ttys. But nothing conclusive.
> 
> In any case a change to Lua is not warranted until the real
> cause for this is found.
> 
> Bye,
>      Mike