- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我的应用程序是一个从命令行使用的简单可执行文件,需要 stdin
作为输入和 stdout
作为输出,因此它的行为类似于许多 GNU 工具。为了测试它,我想设置一个 Eclipse CDT DEBUG 配置 以将文件传递给 stdin
另一个给stdout
.
我试过几个解决方案都没有成功,都在DEBUG Configuration
里面界面:
Common / Standard Input and Output / Input File:
我把inputfile.txt
并在同一部分 Output file:
我把outputfile.txt
.由于 GUI 指示工作目录是 ${workspace_loc:/myprogram}
,它应该没问题,但是当调试器启动时,它会警告: [Invalid file specified for console output: test/WittenACM87ArithmCoding-1.txt.coded]
[Invalid file specified for stdin file: test/WittenACM87ArithmCoding-1.txt]
Arguments
我把< inputfile.txt > outputfile.txt
这显然不是为此而设计的当然,这两个文件都在工作目录中。在 ch = getc(stdin);
上的所有尝试都失败了带有一些奇怪消息的代码行:
Can't find a source file at "/build/glibc-p3Km7c/glibc-2.24/io/../sysdeps/unix/syscall-template.S"
Locate the file or edit the source lookup path to include its location.
这是堆栈:
Thread #1 [myprogram] 31960 [core: 5] (Suspended : Signal : SIGINT:Interrupt)<br/>
__read_nocancel() at /build/glibc-p3Km7c/glibc-2.24/io/../sysdeps/unix/syscall-template.S:84 0x7ffff7811700
_IO_new_file_underflow() at /build/glibc-p3Km7c/glibc-2.24/libio/fileops.c:600 0x7ffff77a9a00<br/>
__GI__IO_default_uflow() at /build/glibc-p3Km7c/glibc-2.24/libio/genops.c:413 0x7ffff77aab02<br/>
_IO_getc() at /build/glibc-p3Km7c/glibc-2.24/libio/getc.c:38 0x7ffff77a54f0
main() at /xxxxxx/src/myprogram.c:20 0x555555554f01
当我直接在控制台中运行该应用程序时,它有效:
./myprogram < inputfile.txt > outputfile.txt
我由此假设 Eclipse 无法实现文件重定向到 stdin
和 stdout
,很明显,我做错了。我已经搜索过了,但是 here和 here不要为我的用例提供解决方案。
因此,为了能够从 Eclipse 使用调试器,设置 Eclipse 的正确方法是什么 DEBUG Configuration
?
最佳答案
事实上,解决方案 1 使用的是与工作目录无关的相对路径。在 GUI 中使用按钮 Workspace...
或 File System...
可以选择已经存在的文件。
例如,对于工作区定义,该字段变为:
${workspace_loc:/myprogram/inputfile.txt}
(输出相同)
而且它有效。调试器说:
[控制台输出重定向到文件:/.../myprogram/outputfile.txt]
关于c - 如何在 Eclipse CDT 应用程序中分配输入文件而不是标准输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50061178/
我是一名优秀的程序员,十分优秀!