编译器在Wine下输出错误,但在Windows上不输出 [英] Compiler outputs the errors under Wine, but not on Windows

查看:163
本文介绍了编译器在Wine下输出错误,但在Windows上不输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有语法错误的.mqh源代码文件,例如通过以下命令创建的:

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

echo some_error > fail.mqh

现在,我正在使用Metaeditor编译器检查语法,我的目标是将错误打印到标准输出(CON),而不是将错误记录到文件(/log:file.log).请参阅:编译.

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.

以下语法在Linux/macOS上可以正常工作,如下所示(也在wine cmd.exe下):

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)

请注意,必须使用/log参数,否则编译器默认不会打印任何内容.因此,如果指定了/log,则默认情况下它将编译结果记录到文件中.而且我正在使用特殊的CON设备来显示错误.

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.

问题是,当我在Windows(cmd)上运行相同的命令时,却没有任何输出:

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

CON:/con:相同.同样在 PowerShell 上.

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

尽管CON适用于echo,例如:echo test > CON.

我可以假定这可能是编译器的错误,但是随后在Wine下可以正常工作.为什么只能在Wine下使用此功能?

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?

是否还有另一种将错误输出到Windows上的终端屏幕而不是日志文件的方法?

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.

推荐答案

根据支持团队的意见,Metaeditor应用程序没有控制台,因此无法将日志输出到屏幕.因此,看来wine对特殊的CON设备的处理方式有所不同.我已将此问题报告给服务台,并且该问题仍未解决,因此他们将来可能会实现对控制台的支持.

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.

当前唯一的解决方法是在编译文件(或在wine下模拟)后,使用type命令对输出日志文件进行控制台.即使编译器可以将其显示在控制台上,它也不能与CI一起正常工作(在处理错误代码方面),因为metaeditor.exe的返回退出逻辑被完全破坏了,因为它返回了成功编译的次数文件而不是错误代码(例如,如果编译20个文件,您将获得20个错误代码?!)!因此,依靠metaeditor.exe的返回退出是一个错误,MQL团队也没有计划对其进行修复,因为他们说这是他们认为应该的工作方式.

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.

这篇关于编译器在Wine下输出错误,但在Windows上不输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆