我在哪里可以找到c-repl文档? [英] Where can I find c-repl documentation?
问题描述
示例:
> int foo(double x){return x + 0.5;}
> FOO(5.5);
> int x = foo(5.5);
> x
px
$ 1 = 6
事情进展顺利,但是: / p>
> #include< stdlib.h>
< stdin>:1:22:warning:#include指令结尾处的额外令牌
所以我想它不喜欢这个...
任何人都知道一个好的教程/博客/引用?
根据 README 文件git存储库,它使用gcc编译每行代码,gccxml用于include指令。
如何工作
该方法非常简单:对于您输入的每行代码,我们
在后台编译共享对象。如果编译成功,
将通过dlopen()将对象加载到子进程中。解析C
#includes
使用gccxml。 (不幸的是,我不知道如何使用
gccxml来解析用户的输入,并且由于解析C
的复杂性,输入解析器目前是hacky和启发式的。)
错误消息与使用gcc获得的文字相同(尽管没有该输入)。也许尝试没有任何空格。
I've just come across the Ubuntu c-repl package which provides a REPL interface for C programming. Great! It is quite excellent for trying snippets and ideas, and intuitive to use. I love it. But there is no documentation at all, and I'd like to find out more about how to drive it.
Example:
> int foo( double x ) { return x+0.5;}
> foo(5.5);
> int x = foo(5.5);
> x
p x
$1 = 6
Things are going swimmingly well but then:
> #include <stdlib.h>
<stdin>:1:22: warning: extra tokens at end of #include directive
So I guess it doesn't like that... Anyone know of a good tutorial/blog/reference?
According to the README file on the git repository, it's using gcc to compile each line of code and gccxml for include directives.
How it works
The approach is surprisingly simple: for each line of code you enter, we compile a shared object in the background. If the compilation succeeds, the object is loaded into a child process via dlopen(). Parsing of C
#includes
uses gccxml. (Unfortunately, I can't figure out how to use gccxml to parse the user's input, and due to the complexity of parsing C the input parser is currently hacky and heuristic.)
The error message is the same wording as the one you get with gcc ( though not with that input ). Maybe try without any whitespace.
这篇关于我在哪里可以找到c-repl文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!