Compiler outputs the errors under Wine, but not on Windows
Asked Answered
G

1

1

I've got .mqh source code file with syntax error, for example created by the following command:

echo some_error > fail.mqh

Now, I'm using Metaeditor compiler to check the syntax and my goal is to print the errors to the standard output (CON), instead of logging them to the file (/log:file.log). See: Compiling.

The following syntax works fine on Linux/macOS as follow (also under wine cmd.exe):

$ wine metaeditor.exe /s /log:CON /compile:fail.mqh
??fail.mqh : information: Checking 'fail.mqh'
fail.mqh(1,1) : error 116: 'some_error' - declaration without type
fail.mqh(1,1) : error 161: 'some_error' - unexpected end of program
 : information: Result 2 error(s), 0 warning(s)

Please note that the /log parameter is required, otherwise the compiler doesn't print anything by default. So if /log is specified, then by default it logs the compilation result to the file. And I'm using special CON device to display the errors.

The problem is when I'm running the same command on Windows (cmd), then I've got no output:

> metaeditor.exe /s /log:CON /compile:fail.mqh

Same for CON:/con: as well. Also on PowerShell.

Although CON works for echo, e.g.: echo test > CON.

I could assume it could be a bug of the compiler, but then it works fine under Wine. Why would this work only under Wine?

Is there another way of outputting the errors to the terminal screen on Windows, instead of log file?


Note: You can install compiler from the site or download the binary (32bit or 64bit) to test above.


Clarification: My main blocker for using two separate commands (compile and print the error log after that) is that CI test may fail before the errors are printed, which makes the tests useless and it's a story for another question. So my goal is to check the syntax and print the errors at one go.

Glyoxaline answered 11/1, 2017 at 0:37 Comment(9)
I'd omit the argument /log:CON and eventually add an error output redirection `2>&1'Celisse
However by default the compiler doesn't print anything to the output, unless /log is specified, so it logs the compilation result to the file by default.Glyoxaline
Looks like metaeditor behaves/interacts differently in these environments. What about trying /log:con:Celisse
Just tested it, same thing.Glyoxaline
Why don't you simply output the log file after the metaeditor command finishes?Celisse
Specifying the filename is the only workaround which I know of (ignoring the fact it's in UTF-16 format, so the system needs to support that as well). Outputting the results to the screen is just more convenient, so I'm looking for some hacks to achieve that. Another downside of two separate commands is that the CI test will fail, before the errors are printed.Glyoxaline
If the output is UTF-16, how does Wine handle it?Oft
The commands type or more should display utf-16 (inside font/codepage limits) properly to the screen.Celisse
@MarkRansom Executing under wine it prints ?? at the beginning, but somehow the rest is fine. Printing log via type on Win10 is fine. On Linux/macOS, cat/vim works fine, but grep/less/more and other tools sees it as a binary file.Glyoxaline
G
0

According to Support Team, Metaeditor application does not have a console, so it cannot output logs to the screen. So it seems wine handles special CON device differently. I've reported the issue to the Service Desk and it's still open, so they may implement the console support in the future.

Currently the only workaround is to use type command for output log file to console after compiling the files (or emulate it under wine). Even if the compiler could display it to the console, it won't work properly with CI either (in terms of handling the error codes), because logic of return exit of metaeditor.exe is completely broken as it returns the number of successfully compiled files instead of the error code (e.g. if you compile 20 files, you'll get 20 error code?!)! So relying on return exit of metaeditor.exe is a mistake and MQL team isn't planning to fix it anyway, since they say this is how it should work in their opinion.

Glyoxaline answered 25/2, 2017 at 21:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.