嵌入式的Lua"印刷"没有从Visual Studio工作在调试模式 [英] Embedded Lua "print" not working in debug mode from Visual Studio
问题描述
我使用Luainterface 2.0.3嵌入的Lua在C#应用程序。
I am using Luainterface 2.0.3 to embed Lua in a c# application.
一切工作正常,但在Visual Studio中的调试模式下,Lua的打印的功能不会被写入到控制台(也不输出)。
Everything is working fine, except in visual Studio's debug mode, the Lua's print function does not get written to the console (nor to Output).
using System;
using LuaInterface;
namespace Lua1 {
class Program {
static void Main(string[] args) {
Lua lua = new Lua();
lua.DoString("print 'Hello from Lua!'");
}
}
}
在非调试模式下运行它,打印的是工作的罚款。
Running it in non debugging mode, print is working fine.
我缺少的东西?
谢谢!
推荐答案
不幸的是,你可能是反对在打印一个已知的缺陷()
函数,这是真的用于快速和肮脏的调试在控制台提示符,而缺少一些必要的灵活性。
Unfortunately, you are probably up against a known deficiency in the print()
function, which is really intended for quick and dirty debugging at a console prompt, and is missing some necessary flexibility.
该基地的库函数打印()
通过的 luaB_print()
在lbaselib.c 明确使用C运行时的标准输出
流作为它的目的地。因为它是指全局变量标准输出
明确在实施,它重定向的唯一方法是使该文件句柄被重定向。在C程序中,可以通过调用来完成则freopen(标准输出,...)
。不幸的是,没有一个股票库函数在Lua中,可以做到这一点。
The base library function print()
implemented by luaB_print()
in lbaselib.c explicitly uses the C runtime's stdout
stream as its destination. Since it refers to the global variable stdout
explicitly in its implementation, the only way to redirect it is to cause that file handle to be redirected. In a C program that can be done by calling freopen(stdout,...)
. Unfortunately, there isn't a stock library function in Lua that can do that.
在 IO
库在 liolib实施。 Ç。它使用功能环境保持打开的文件描述符的表,它的初始化过程中它创建命名的文件
对象 io.stdin
, io.stdout
和 io.stderr
三个标准描述。它还提供了一个名为功能 io.output
和 io.input
来让这两个描述进行修改,以指向任何打开文件
对象(或者,如果一个文件名是通过一个新打开的文件)。然而,这些功能只改变功能环境的表,不叫则freopen()
修改文件
值。
The io
library is implemented in liolib.c. It uses the function environment to hold a table of open file descriptors, and during its initialization it creates file
objects named io.stdin
, io.stdout
and io.stderr
for the three standard descriptors. It also provides functions named io.output
and io.input
to allow those two descriptors to be modified to point to any open file
object (or a newly opened file if a file name is passed). However, those functions only change the function environment table and do not call freopen()
to modify the C runtime's table of FILE
values.
我不知道LuaInterface如何试图把标准输出
标准C运行时的想法。这很可能是因为标准输出
未连接到任何有用的东西在VS调试器,因为它可能需要一些.NET功能优势,捕捉来自模块的输出被调试的可能不是所有用C在任何情况下不兼容。
I have no idea how LuaInterface attempts to treat the standard C runtime's idea of stdout
. It may very well be that stdout
is not connected to anything useful in the VS debugger because it probably takes advantage of some .NET feature to capture output from the module being debugged that may not be all that compatible with C in any case.
这就是说,它是易于更换的标准打印
功能。只需使用LuaInterface现有的功能编写了一个名为全局函数打印
调用的ToString()
对每个参数,并将其传递到任何.NET的事情是标准的输出设备。
That said, it is easy to replace the standard print
function. Just use existing features of LuaInterface to write a global function named print
that calls tostring()
on each argument and passes it to the whatever .NET things is the standard output device.
这篇关于嵌入式的Lua"印刷"没有从Visual Studio工作在调试模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!