Edit and continue with C++? Preferably with Code::Blocks? - c++

I am used to Java and Eclipse, as that was what I first programmed with. That said, in Eclipse, when debugging Java, you can make code changes, and save them, while the code is running. The changes to the code will then take effect in the debug window, without a change to your code.
I am wondering if you can do the same thing, or similar with C++. I am currently using Code::Blocks, and I'm wondering if there is a debugging plugin for it that does the same thing, or similar. I know about Edit and Continue in VS, but I would really rather stick with Code::Blocks. Also, I have not programmed C++ in Eclipse yet, and will hot swapping C++ work in Eclipse? Or is that a Java feature?

What you're looking for is a feature of the entire toolchain, including the compiler, linker, loader, and debugger. Visual C++ has this feature because Microsoft has made all its tools work together to support it. Similarly, the same effort has been spent to make Java work this way.
As far as I know, Code::Blocks is just an editor but delegates the compiling and linking to other compilers (without specifically integrating with their features).

Java is JIT compiled (just in time, compiled at runtime) making this feature, perhaps not trivial, but not as significant a challenge as it is to implement in a C++ environment. I've been developing in Visual Studio for 10+ years now, and to be honest, I find edit and continue rather useless.
As to having it in Code::Blocks, gcc would have to support incremental compilation before this was put significantly on the agenda of many C::B users. There was a project to add this functionality, but I'd say at this stage, you're out of luck.

Related

Windows programming using MinGW

Firstly, please forgive my ignorance regarding these matters, I have done a search and not found any comprehensive answers as of yet.
I plan on learning how to develop for Windows, however I am very fond of the GNU toolchain and don't really want to move onto using big environments like Visual Studio until I feel more comfortable with the underlying basics.
From what I understand, one can download the Windows SDK, which contains the headers and libraries needed to build native Windows applications.
Is the SDK literally just a collection of libraries and headers? If so, as my logic goes, it should be possible to point MinGW towards these libraries/headers, and simply build as normal.
When I build using Visual Studio, I can't see what preprocessor directives are being defined, what is being linked in etc. etc., as I am still learning, I like to be able to know exactly what is going on, preferably so I have to manually define, link etc. Hence the question.
So, what I want to know: is my logic correct?
Again, apologies if the question is rudimentary, I am still learning.
P.s. I am planning to develop Windows applications in a windows environment, this is not a question regarding cross-compilation.
Thanks!
MinGW is not compatible with the official Windows SDK, with one of the reasons
being that the SDK contains many VS-specific things (opposed to the GCC base
on MinGW). MinGW has adapted many of the necessary files, and for many programs
this is enough.
You don´t need to know the VS project settings for some program;
MinGW is still GCC in the core and used as such. If you can compile
programs with GCC on linux, learning how to use MinGW won´t be hard.
If you need functions/structures/etc. which are not yet part of it,
you´re out of luck, other than doing the adaption yourself, which
can be everything between very easy or very hard, depending on the case.
Additionally, proper thread usage is a bit quirky (has some "hidden" pitfalls,
which could go unnoticed in an actual program for years, but then...).
(While this is a disadvantage to VS, you´ll get C++11/14 (while VS hasn´t
even finished with 11, see link), better optimzation in many cases etc.)
If you´re choosing what exactly to download, look at WinGW-W64 instead of
the "original" old one. The original project somewhat stopped, has poor
lib support compared to W64, no 64bit compiler etc. (and don´t misunderstand
the "W64", it can be used for 32bit programs too)

Using Eclipse with C++Builder 2007?

I have several (huge) projects written with CodeGear C++Builder 2007, making use of components, forms/"designs", etc.
Problem: The IDE sucks, especially the lack of proper navigation in the code gets on my nerves. I'm looking for an alternative IDE to use at least for the actual coding (and maybe for forms-design as well) that can read C++Builder projects (.cproj files).
I thought, if any open IDE can do it, its Eclipse... Other alternatives are welcome if you know them. But before I spend too much time trying to figure out how to make that work--- Does anyone have experience with this and can confirm/decline whether I can use Eclipse to work on C++Builder projects?
Yes, Eclipse works as an IDE with C++Builder. I regularly do my coding in Eclipse and use C++Builder for the compiling, form designer, and debugging. (Eclipse should be able to invoke a command-line build of C++Builder and look for errors, but I've never tried this.)
Eclipse doesn't need to be able to read .cbproj files; instead, create an Eclipse project in the same directory as your C++Builder project, manually set up your Eclipse paths and includes to match your C++Builder project, and let Eclipse go from there.
I'm currently using Eclipse Helios, which is rather old. Newer versions of Eclipse CDT improve its ability to parse C++, but unfortunately, this seems to cause it to reject more of C++Builder's C++ extensions. I haven't yet investigated to see how to best handle this.

Setting up windows for C++

To quote the FAQ, 'No question is [...] too "newbie"'
What is the best way to set up an Windows system (vista, if that matters) to work with C++?
Preferably with a nice IDE, easy compiling of software (support for make files, etc.), but suitable for a beginner.
I would quite like the IDE to use a relatively portable format, such as makefiles and configure scripts, nothing too proprietary.
I would also like the ability to add new libraries etc. without much hassle, and work with the majority of C++ code others have written.
I am comfortable using the command line.
Thanks for the help, hopefully the question is clear. And apologies if it's already been answered, i did have a look for similar questions.
I know this is not exactly 'nothing to proprietary' but you should give a look at the free Express Edition of Visual C++. Under its covers you'll get all the familiar make and command line tools, but wrapped in a polished IDE.
If you're really comfortable with the command line then you can make an IDE from code editor on top of a compiler/debugger suite. MS's own command line tools come with the platform SDK (free) and you get an awesome debugger in Windbg. My personal favorite code editor is Code Insight. I wish so hard for a Mac version /sigh.
Microsoft's Visual Studio has a free express edition which contains pretty much everything you need to program c++.
For a Gui, the main choices are probably, MFC (old and ugly), CLR/.Net (new and confusing) or look at Qt(now LGPL) or wxWigets
There are quite a few good IDEs for C++ available on Windows.
The de-facto standard for professional software development is Microsoft's Visual Studio, which is available in different versions, like the free Express Editions. This will give you a great tool-chain for Windows development.
However, for a more "cross-platform" approach, you should have a look to the free Eclipse C++ Development Tooling, which is available for many platforms. As long as your own code is platform-independent, the whole project can be shared between Windows, Linux, Mac, etc.
Other alternatives are MinGW or CygWin that both allow to use the GCC toolchain on Windows.
Try the MinGW compiler, it will come with a C and C++ compiler, Make, etc--among many others. This can be used from the command line, pretty easily: g++ -o someprogram.exe somecode.cpp
As for an IDE, there are lots out there. Right now I am using Code::Blocks, and so far it's been really nice. As well, it already supports the GCC compiler, and sets many of the appropriate flags for you, so all you'll really need to do is hit the "build" button.
Some others you might want to try are Eclipse, which is really powerful, but lots of its "power" will be really confusing and difficult to use until you start getting used to it. Visual C++ is another one, which (obviously) would integrate very nicely into Windows. Of course, you could always use emacs :)
I suggest you evaluate CodeBlocks.
Microsoft's Visual Studio is powerful but rather proprietary. If you prefer open/portable stuff, I recommend Dev-C++ and Cygwin.
FWIW, I recently went through this and tried the VC++ Express and QT Creator based stuff. Coming from a linux/unix background I found that QT was a little better since it was using the Ming compilers and some make based constructs.
If you will only be hacking for windows I would go for Visual Studio. It will definitely save you time you can spend on coding instead. Most open source out there for windows either already have VC project, and if they don't it is usually very simple to set one up. And normally they have either make or nmake files for you to build VC compatible libararies to link with.

Need a c++ compiler to work with libraries (boost, ...)

Currently I`m using Visual Studio for writing code in C++. But it seems so weighty that I decided to switch for another one, preferably free, not so strict to system resources (I mean memory, of course) as VS to learn libraries, such as Boost and Qt. What compiler do you suggest?
I'd suggest using Visual Studio's compiler from the command-line. You get the same high-quality compiler, without the resource-hogging IDE.
Although the IDE is pretty good too, and probably worth the resources it uses.
Code::blocks is exactly what you are after. You can can download it here: http://www.codeblocks.org/downloads/5
Choose the version with the mingw compiler bundled with it (Windows port of GCC). You can switch between that and the VC++ compiler as and when you like.
Code::Blocks has all the stuff you want, debugger integration, code completion, class browser, todo list etc. etc. It even import visual C++ projects.
Don't use Dev C++ which has already been recommended. It's very very old and outdated.
If you want to learn unix tools download and install cygwin It's a good set of tools but a full install takes up 5 or 6 gigs because so much is included.
There is always Digital Mars. Also, you can freely download Microsoft WDK
which comes with their C/C++ compiler and command-line build system.
You will be hard-pressed to find an IDE as capable as MS VS. It is incredibly feature-rich.
However, if you just want command line compiling and linking it can do that too.
GCC is also an option.
Please note that you do not need another compiler or IDE to use boost libraries. I wouldn't replace Visual Studio with any other IDE/compiler, at least not on Windows. Installing Cygwin or SUA (better than Cygwin, closer to the Windows Kernel) will only be a pain just for what you are trying to reach.
Try to minimize the memory usage by disabling unnecessary things, keep the amount of open source files small, use an alternative to document explorer to find help (your browser on msdn will do). Besides that, I wouldn't call a few ten megabytes of memory a high usage. As long as it doesn't slow your system down there is not a real issue.
A better idea would be to upgrade your computer rather than to replace something powerful with something that you don't know.
Seriously there is no real alternative to Ms's compiler on Windows. All the others are OK if you can't spring for Visual Studio or if you are just doing hobbyist work. Cygwin can be a pain to deal with.
If you don't want the IDE as someone else suggested just use the command-line compiler.
I've found VS to be quite good for doing Boost + Qt work. Especially if you have the Qt + VS integration tool. You get a GUI designer and respectable Qt project management tools.
If you are looking for a compiler that uses fewer system resources than the MS ones, you'll probably find that most modern compilers that are able to compile a good part of or almost everything in Boost will be quite heavy on system resources, both processor usage and memory consumption. To a certain extent that's just par for the course when it comes to C++.
That said, I do like to have a second compiler around if I'm writing portable code as it's a lot easier to iron out portability issues when you can ensure that the code compiles in different environments. If you want to do all that on Windows, may Cygwin is worth a look. However it does seem that the GCC you get with Cygwin is not exactly what you'd call up to date.
The aforementioned Digital Mars compilers are well worth a look, Walter Bright (the guy behind them) has been writing C++ compilers for a long time and they're pretty good. I have used them off and on since the early nineties and I've always been happy with them. Not to mention that they always seemed noticeably faster than the Microsoft offerings, but I haven't got any recent measurements to back that up.
At the end of the day, most third-party tool vendors on Windows tend to target the MS environment so if you're writing C++ code professionally and need/want tools like leak detectors, you pretty much need to be able to build with the MS compilers, even if they aren't your main development environment.
I sugget , Netbeans.org
NetBeans IDE , download the Cygwin , follow one tutorial from http://www.netbeans.org for C++ confuguration at Netbeans IDE , just 2 steps.. and u are ok
autocomplete (faster than VS')
classes
and all... you want xD
It needs to mention about DevCpp. It is a simple UI wrap for gcc compiler (oh my, it is sounds like a tautology). It provides lightweight IDE but not so stable (so, its IntelliSense is somewhat buggy).
If you use Qt why not use their IDE, QtCreator, there is compiler, debugger and GUI designer. All comes in one nice package and works on Windows, Mac and Linux.
In my opinion it's better than Code::Blocks (also based on MinGW/GCC).

C on Visual Studio [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm trying to learn C. As a C# developer, my IDE is Visual Studio. I've heard this is a good environment for C/C++ development. However, it seems no matter what little thing I try to do, intuition fails me. Can someone give good resources for how to either:
learn the ins and out of C in Visual Studio
recommend a better C IDE + compiler
Edit: See also: https://stackoverflow.com/questions/951516/a-good-c-ide
well you can use visual studio just fine take a look at here man
http://www.daniweb.com/forums/thread16256.html
Go to View Menu select Solution Explorer or CTRL+ ALT +L
Then Select The project that your are developing and right click on that.
Then select the Properties from the submenu.
Then select the Configuration properties from the Tree structure. under that select C/C++ then select Advanced. Now in the right side pane change the property
Compile As from Compile as C++ Code (/TP) to Compile as C Code (/TC)
Finally change your file extensions to .c
Now you configured you Visual Studio to compile C programs
And you can use NetBeans too it could even be more user friendly than Visual Studio download it you wont regret i promise
The problem with learning C within Visual Studio is that you are compiling C using the Visual Studio C++ compiler. You might want to try learning C using the GNU GCC compiler from within the Cygwin environment in Windows.
Answering the purely subject question "recommend me a better C IDE and compiler" I find Ming32w and Code::blocks (now with combined installer) very useful on windows but YMMV as you are obviously used to the MS IDE and are just struggling with C.
May I suggest you concentrate on console applications to get a feel for the language first before you attempt to tie it together with a windows UI which in my experience is the hardest bit of windows development.
Simple and sweet: Console applications (basic C programs using printf and such) are easily and cheaply done with the Tiny C Compiler - a no frills, no gui, complete C complier.
http://bellard.org/tcc/
However, C development is relatively simple on Visual Studio as well. The following instructions will set Visual C++ up as a good C compiler, and it will produce console applications at first, and yo can move up into more complex windows apps as you go.
Get the Visual Studio C++ edition (express is fine)
Start a new project - disable pre-compiled headers (maybe the wizard will let you do this, maybe you'll have to change the compiler settings once inside the project)
Delete everything inside the project.
Create a new "example.c" file with the hello world example
Compile and away you go.
Alternately, get a linux virtual machine, or Cygwin. But as you already have Visual Studio, you might as well stick with what you know.
As an aside, this isn't Atwood learning C finally, is it? No ALTs! ;-D
-Adam
Bloodshed Dev-C++ is the best windows C/C++ IDE IMO: http://www.bloodshed.net/
It uses the GNU compiler set and is free as in beer.
EDIT: the download page for the IDE is here: http://www.bloodshed.net/dev/devcpp.html
As already said, you should check out the VS.net C++ edition, but if you'd like to try something else Eclipse has a C++ edition. You can get more info from http://eclipse.org or check out the distro at http://www.easyeclipse.org/site/distributions/cplusplus.html
The problem with learning C within Visual Studio is that you are compiling C
using the Visual Studio C++ compiler. You might want to try learning C using
the GNU GCC compiler from within the Cygwin environment in Windows.
This is a legitimate response, I posted an IDE that uses the GNU compilers, so why has he been down modded?
This is the type of thing that will make me not use SO, why down mod someone just because they are recommending a different compiler, and IMHO, a better one then Microsoft's?
get real people, and #Antonio Haley I gave you +1
http://xoax.net/comp/cpp/console/Lesson0.php
Any use?
Some people say that a smaller IDE is better for learning. Take a look at Code::Blocks. It's generally true that beginning C in an IDE is hard because not many books explain enough to control the IDE. Perhaps starting in a console and a basic text editor with syntax highlighting would be better – at least under Linux. Since Windows' console is far from great, I'd not recommend using it.
/EDIT: Dev-C++ used to be the best freely available IDE for Windows. However, it's development has been discontinued years ago and the most recent version unfortunately is full of bugs.
There's a very good reason to learn C and C++. The reason is that there's a lot of C and C++ code out there that are performing very real and important tasks. Someone who considers themselves a programmer and a learner(doubtful that you can separate the two) can learn a lot from these lines of code.
You can learn a lot from each language by studying the other, but if you really want to grok C it's a lot easier to separate yourself from anything C++ for a while. Visual C++ is great but GCC is a great way to thrust yourself into vanilla ANSI C without having to mentally sidestep any C++.
#mmattax thanks!
C in Visual Studio is fine, just use the command line compiler that is included in the Pro edition. Yes its the C++ compiler but treats all files ending .c as C . You can even force it to treat ALL files as C with a switch. The VS documentation has entries on it, just search the index for Visual C.
Visual Studio is one of the best IDEs for C/C++.
I don't think it is complicated and hard to use - if you have questions about it - ask them.
Some other compilers/IDEs are fine too, but if already have Visual Studio and have used it - why not stick to it?
For plain C, I suggest Pelles C. Generates optimized code and supports C99 constructs.
Features:
Support for 32-bit Windows (X86),
64-bit Windows (X64), and Windows Mobile (ARM). Support for the C99 standard.
Integrated source code editor with call tips and symbol browsing. Integrated source-level
debugger. Project management.
Inline assembler for X86 and ARM.
Integrated resource editor. Integrated bitmap, icon and cursor editor. Integrated
animated cursor and video editor.
Integrated hex-dump editor.
Supportfor custom controls in the dialog editor. Support for custom project wizards.
http://www.smorgasbordet.com/pellesc/
When i used visual studio 5.0 it should compile c code as long as the header files and lib. are there for the compiler to find. In fact most C++ compilers like G++ will compile C code just fine. But i'm not sure how well.. If you are targeting a platform then you can change the header files and lib. within you IDE and Compiler.
Visual Studio has a great debugger that no other Compiler that i have seen can compete with. I have been using gcc darwin10 4.2.1 and find the debugger is basically just the one you can getfree with any linux flavor. I recommend you learn both on a plain vanilla gcc compiler and also try visual studio which costs money. The express edition does not allow the use of threading and several other things that I forgot about. Visual Studio 5.0 should be ok to use and the debugger is much more human friendly then the one commandline version called GDB. Try DDD on linux which is similar to XCODE's debugger.
Although C++ and C are different you can compile both together. But you should understand each ones flaws and good points. C code is faster, but C++ is much easier to write and manage larger code. C++ is object oriented but C is procedural while they are both imperative languages. I would suggest learning objective-C since you can use both C++ and C libraries. Using the features you like in all three languages!!!
Visual Studio or Express do consider .c files as C code, but the compiler will keep giving warnings, and irritating suggestions which you do not require, in the debugger. Gives an indication that Visual C++, as the name suggests is optimized for C++ development for the Windows Operating system, which was originally written in plain pure C.