【发布时间】:2012-06-01 18:33:18
【问题描述】:
我在 osx 上。我找到了这个 http://neugierig.org/software/c-repl/ 但是该页面上的代码链接似乎已损坏。
【问题讨论】:
-
只需在这篇文章中添加一个链接以及一些 c-repl 示例:stackoverflow.com/questions/1459678/…
我在 osx 上。我找到了这个 http://neugierig.org/software/c-repl/ 但是该页面上的代码链接似乎已损坏。
【问题讨论】:
似乎 c-repl 的代码现在可以在 Github repository 找到。不过,这似乎是一个死项目(最后一次提交是 3 年前),所以我建议也寻找替代方案:
【讨论】:
刚刚找到IGCC(交互式 GCC)REPL。我喜欢。
例子:
./igcc
g++> int a = 1, b = 2;
g++> printf("%d\n", a + b);
3
g++>
它会给你这样的编译错误:
g++> c = 3;
[Compile error - type .e to see it.]
g++> .e
<stdin>:14:1: error: use of undeclared identifier 'c'
c = 3;
^
【讨论】:
gdb 是一个非常好的 REPL。你不能在那里定义新的函数,但你可以计算表达式(包括那些有副作用的)。
【讨论】:
gdb /bin/ls 2) print "Hello world"[0] 当然它比这更复杂......但即使是这个简单的例子也说明了一个常见的 C 习惯用法在 repl
(gdb) print printf("test\n"); No symbol "printf" in current context. 这很有趣,因为我刚刚跳过了对 printf 的调用!