3 ms·
C-REPL
- chasingsparks 17y agoFrom the README: 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.) While I agree that this may be an elegant (simple) way of doing things, how responsive is the compilation process for the RE portion of REPL? Even a one second wait time might seem tedious.
- ivanstojic 17y agoI've used C-Repl quite comfortably for smaller hacks and tests. While it's not a true REPL, it can certainly help along for simple use cases.
- mbrubeck 17y agoOn my four-year-old "Pentium D" workstation, it's not quite instantaneous but close enough for interactive work.
- chasingsparks 17y agoThanks for the feedback. Now that I'm home, I'm going to install.
- wingo 17y agoI often use gdb as a C repl. You can't build a program that way of course. This OTOH is a nice hack :)
- habitue 17y agoWhen I began using gdb heavily recently I was pleasantly surprised that it had this capability. It's really an amazing program, I wish I hadn't been so scared to use it before
- rick2047 17y agoLots of UNIX tools are just plain scary at first, but if you look at them closely you would see they are so powerful once you start using them
- Erwin 17y agoThere are C interpreters around, like "cint" -- http://root.cern.ch/drupal/content/cint http://root.cern.ch/drupal/content/cint -- which is somewhat more stable, having been around since 1995. This C-REPL one seems to have the advantage of using gcc directly while cint is basically its own compiler. If being able to "evaluate" C code like that gives you some ideas, you might want to have a look at "libtcc" -- which seems to be getting some development love again compared to last time I looked at it (finally an x86-64 target). (I have some higher level code that converts well to C that libtcc or a gcc/dlopen approach would be nice for)
- yan 17y agoThere's also ccons[1], which is a similar idea but built on top of Clang/LLVM. [1] http://code.google.com/p/ccons/ http://code.google.com/p/ccons/
- mbrubeck 17y agoI had to make some minor changes to get it to build under Ubuntu 9.10 with Haskell Platform 2009.2.0.2. I pushed them to a GitHub fork here: http://github.com/mbrubeck/c-repl http://github.com/mbrubeck/c-repl
- deleted 17y ago[deleted]
- sbt 17y agoHow does this find and load shared objects?