Reputation: 14372
I'm usually using Visual Studio, but several things bother me when I just quickly want to test some code:
getchar()
or a breakpoint in the program and thus I'm not seeing it.I'm looking for a program which is suitable for a really, really quick programming in Windows. Such as, copying some code from an SO question, running it and seeing its output.
I don't think that console programs or g++ under CygWin are a good solution, because there it takes ages to cd
into the right dir to save the file, I'm not used to editors such as Vim, and typing in the compiler commandline myself has always annoyed me etc.
So I guess what I'm looking for is a very lightweight free C/C++ IDE which is preconfigured to work with a free compiler (bonus points if it is even shipped with it.)
What can you recommend which adresses at least two items from the list above?
Is there maybe even a program which can execute/interpret C or C++ in an interactive commandline (like Python)?
Upvotes: 19
Views: 61204
Reputation: 1
You can use both MinGW and Microsoft C/C++ optimizing compilers for quick start. No installation is needed, also no administrator privileges too. Microsoft C/C++ compiler is used via EWDK. Also, these compilers can be used from removable devices, such as USB flash sticks. Details are described in the book "Beginning C++ Compilers" which can be found in the Internet
Upvotes: 0
Reputation: 3861
I'm looking for a program which is suitable for a really, really quick programming in Windows. Such as, copying some code from an SO question and executing it and seeing it's output.
For quick-and-dirty experimental coding, I really like codepad.org. Not having to create a file is especially nice as it saves me from coming up with a suitable name and disk location. Be aware that it uses g++ 4.1.2 behind the scenes so some of the latest C++11 features aren't supported.
Upvotes: 9
Reputation: 66922
On my machine, I have a "empty" project called "Test". When I want to test some random code on the internet, I simply put it into main.cpp
in that project, and compile.
If you think MSVC takes too long to load, it should be possible to write a batch script that attempts to compile the project and puts the build log in a file. Then you can simply alter the existing main.cpp
with notepad, double click the batch file, then pop open the build log or run the executable.
[Edit] I made a batch file to compile the entire solution. Turns out that requires loading visual studio. However, the batch file can compile/run a single cpp file easy enough.
Upvotes: 2
Reputation: 187
First off, your expectations are not reasonable. no program can guess what you want, over a range of input from the simplest to the most complex. If cd'ing into cygwin is too hard, and starting up visual studio is too time-consuming, you're pretty much toast. Sorry.
That said, you can edit code with notepad (which you can invoke from the command line as notepad foo.cpp). Notepad uses your mouse and the arrow keys on your pc so it's pretty intuitive.
you can use visual studio tools from the command line, without having to fiddle with project files.
Visual studio comes with a tool called nmake, the most basic usage of which is similar to linux make. If you have very simple input, nmake's default rules may be good enough to produce an executable. If not, you may be able to construct a makefile that will take any single simple file, say foo.cpp, and compile and link it to an executable called foo.exe. You'll still have to learn to use nmake, which some people think is easy, and others think is fiendishly difficult. Try nmake foo.cpp and see if the result is what you want.
Upvotes: 0
Reputation: 62048
Open Watcom is easy to install and use, it's fast and it's the closest compiler to MSVC++, although it's noticeably behind in features (especially in C++).
I don't use its IDE at all as I got used to doing most of the stuff in the console, but it's there and the debugger is there too.
Compiling one-filers is easy.
Compiling C code:
wcl386.exe /we /wx /q sourcefile.c
Compiling C++ code:
wcl386.exe /xs /we /wx /q sourcefile.cpp
Upvotes: 2
Reputation: 126787
Once I used PSPad setting its "compiler" option for C++ files to a reasonable default (cl.exe
in the correct directory, speed optimization, all warnings). Then it's just Ctrl+F9.
Upvotes: 1
Reputation: 545588
Which compiler you use doesn’t really matter. I prefer G++ but cl.exe
(from Visual Studio) works equally well.
In order to use the compiler quickly from the command line, either
.cmd
script which launches a console with the right paths included.Visual Studio incidentally comes bundled with such a .cmd
script which is linked in the Start Menu entry of Visual Studio. Personally, though, I prefer adjusting the PATH variable.
Then you can simply invoke the compiler from any directory in the command line. If you are too lazy to write the whole command line, create a script to do it for you. Or use Cygwin and (C)Make.
Two additional remarks:
Starting the project using the build configuration (Cntr+F5 (?)) leaves the console open after the program has run, without you having to include getch()
calls or similar.
I highly recommend you learn an editor such as Emacs or Vim, unless you plan never to use any other platform than Windows, and even then. These editors are just tremendously powerful, and in some ways light-years beyond what the Visual Studio code editor offers.
But if you really don’t have the time, use a decent text editor such as Notepad++ instead.
Upvotes: 3
Reputation: 108978
tcc -run main.c
Note that with -run
parameter you're invoking tcc
like an interpreter
Upvotes: 6
Reputation: 6834
"really, really quick (and dirty, throw away?) programming "?
Upvotes: 5
Reputation: 8826
My favorite IDE: http://www.codeblocks.org/
Here is a direct link to the download that includes the MinGW compiler: http://download2.berlios.de/codeblocks/codeblocks-10.05mingw-setup.exe
You're not gonna find any (good) C/C++ interpreters.
Upvotes: 1