 |
 |
 |
 |
| Programming A place to discuss programming and development |

2009-10-29, 10:09 AM CDT
|
|
Registered User
|
|
Join Date: Nov 2006
Posts: 409

|
|
|
Interactive C/C++ interpreter on Fedora?
Is there a C/C++ interpreter similar to PHP, Python, Ruby etc, that I can use to run C programs a line at a time, without compiling the C code?
Does Fedora 8+ come with anything like this in the repos?
TIA
|

2009-10-29, 12:13 PM CDT
|
|
Clueless in a Cuckooland
|
|
Join Date: Mar 2006
Posts: 2,733

|
|
|
Because C and C++ are compiled languages unlike PHP etc, not really. What you can do is to run the code in a debugger, GDB for example, to see what happens, where and when.
__________________
F9 x86_64
Lian-Li SILVER CLASSICAL SERIES
MSI K9N2 Diamond
AMD Phenom 9850 BE
XFX GeForce 8800 GT Alpha Dog 512MB GDDR3 HDTV/Dual DVI
8 GB Corsair DDR2 800MHz/PC2-6400 XMS2 DHX
2x Seagate Barracuda 7200.10 320GB S300 RAID 1
Philips Brilliance 200W 20.1"
|

2009-10-29, 12:55 PM CDT
|
 |
Registered User
|
|
Join Date: Sep 2008
Location: Tallahassee
Age: 25
Posts: 208

|
|
|
There is one called Ch that interprets C, but it doesn't support C++ IIRC. It's not really the best idea in my opinion though. If you are doing something where compiling a program is annoying, having to use C at all will be *way* more annoying.
What are you actually trying to do?
|

2009-10-29, 09:29 PM CDT
|
 |
Registered User
|
|
Join Date: Jul 2007
Location: Beijing, China
Posts: 860

|
|
|
Maybe he just wants to learn about C but don't want to go over the make - run - break - edit - make stuff over and over again. Being able to see the disastrous results at once is sometimes considered a virtue. run - break - run - break - run - break - run - win.
__________________
Those who can, do. Those who can't, loop.
|

2009-10-30, 08:43 AM CDT
|
|
Registered User
|
|
Join Date: Nov 2006
Posts: 409

|
|
Quote:
Originally Posted by Simian Man
There is one called Ch that interprets C, but it doesn't support C++ IIRC. It's not really the best idea in my opinion though. If you are doing something where compiling a program is annoying, having to use C at all will be *way* more annoying.
What are you actually trying to do?
|
All I want to do is to run small examples of C code in an interpreted environment, to save doing the compile, link and run stuff.
I've seen the Ch website. There is also this one here:
Cint: http://root.cern.ch/drupal/content/cint
I was wondering if they or something similar was packaged for Fedora 8+?
Save me the trouble of compiling and messing with the source code.
Note: I'm using Eclipse and CDT for compiling and debugging C/C++ code, which is brilliant. However, it seems overkill to start Eclipse, and create a project just to test a few lines of C code.
Last edited by CD-RW; 2009-10-30 at 08:46 AM CDT.
|

2009-10-30, 06:23 PM CDT
|
 |
Registered User
|
|
Join Date: Jun 2004
Location: Laurel, MD USA
Posts: 2,731

|
|
Quote:
Originally Posted by CD-RW
However, it seems overkill to start Eclipse, and create a project just to test a few lines of C code.
|
Yeah, that's what this is good for:
Code:
g++ test.cpp -o test
./test
|

2009-10-30, 06:32 PM CDT
|
 |
Administrator
|
|
Join Date: Dec 2004
Location: Canada
Age: 18
Posts: 9,027

|
|
If you want, you can alias these commands which do roughly what you would expect from an interpreter:
Code:
cat > tobeinterpreted.cpp << EOF && gcc tobeinterpreted.cpp -o tobeinterpreted && ./tobeinterpreted;rm tobeinterpreted.cpp
Just start typing the file and put "EOF" on its own line to exit editing mode and start compiling.
|

2009-10-30, 06:54 PM CDT
|
 |
Registered User
|
|
Join Date: Jul 2007
Location: Beijing, China
Posts: 860

|
|
|
I don't believe that's what the OP wanted. Not interactively enough.
__________________
Those who can, do. Those who can't, loop.
|

2009-10-30, 07:00 PM CDT
|
|
Registered User
|
|
Join Date: Aug 2009
Location: Waldorf, Maryland
Posts: 303

|
|
|
I just use three windows - one for edits, one for compile, one for execute/debug.
That way any compile errors (with line numbers) are immediately accessible, and can be correlated with the
source.
|

2009-10-30, 07:19 PM CDT
|
 |
Registered User
|
|
Join Date: Nov 2006
Location: Detroit
Posts: 2,598

|
|
Quote:
Originally Posted by CD-RW
|
Cool, I never knew there was such a thing. This is helpful. I use something similar for Java.
|

2009-11-03, 02:08 PM CST
|
|
Registered User
|
|
Join Date: Nov 2006
Posts: 409

|
|
Here's the homepage for Ch:
http://www.softintegration.com/
Ch is an embeddable C/C++ interpreter for cross-platform scripting, shell programming, 2D/3D plotting, numerical computing, and embedded scripting. Ch is a free and user-friendly alternative to C/C++ compilers for beginners to learn C/C++. Ch is the solution for:
* Embedded Scripting
* Enterprise
* Academic
* Numerical Computing
* Web-Based Computing
Nice to have this or CINT packaged with Fedora
Both would be even better - LOL
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Automatic Translations (Powered by  ):
All times are GMT -7. The time now is 08:46 AM CST.
|
|
 |
 |
 |
 |
|
|