Home » Language IDEs » C / C++ IDE (CDT) » Some advice/ideas on use of CDT for C++(11) development
|Some advice/ideas on use of CDT for C++(11) development [message #1070816]
||Thu, 18 July 2013 18:34
| Programmist Setevik
Registered: January 2013
Will provide some of the knowledge required for worry-free experience with CDT.|
- my experience is with Linux (Fedora, Mint/Ubuntu), gcc, 4.8.x and clang++
- MUST use gcc 4.8+ or clang 3.3+ for C++11 support. gcc 4.8 was released short time ago, followed by subsequent patch release. Some Linux distros have it available for simple install via "apt-get" or similar, some distros might require pointing to 3rd party repos. 4.8+ is what you want for almost 100% C++11 support. One of things missing is the Regexp.
If you want to custom-complile gcc, limit enabled languages to C,C++ (it is a "configure" option).
Clang is part of LLVM project. Latest prod version is 3.3. Clang is a C++11 open source compiler. It also has its own lib stdc++ version, but compiling it on Linux requires quite some work and I don't think it is production grade just yet, when it comes to Linux. YMMV. But, you can always compile with clang++ to see if it catches hard-to-find bugs that g++ might have missed.
- to install CDT, download the distro file and uncompress it into a directory of your choosing, for example /usr/local/eclipse . To start eclipse, simply run /usr/local/eclipse/eclipse . Note that eclipse requires
java runtime to run
- Most Linux distros already come with open source Java. You can also install Sun/Oracle JRE or JDK from java.com
- CDT makes it extremely easy to navigate a code base - find declarations, uses of, refactor,etc etc. The list is really long, bottom line is: you can work, with absolute ease/comfort with giant code bases. Best IDE one can imagine, period.
- I most highly suggest using Makefile-driven projects - then you can have full control over how and what gets compiled/executed. Takes frustration out of the process. Plus, it imports all the include paths, so you dont have to provide them separately. Make sure Makefile is configured to run tests upon every build.
After creating your directory tree, complete with a Makefile, simply import it into Eclipse as "File" -> "New" -> "Makefile project", enable indexing, done. For an excellent write up on a template Makefile structure, read Zed Shaw's C guide.
- If you already have a Windows box, you dont need dedicated Linux HW. Go with Virtual Box - it works great on Windows and you can install as many different Linux guests as you want. Works 100%. Seamless mode is to die for. Some Linux distros are friendlier than the others when it comes to seamless mode. I suggest Mint15 or latest Fedora. Dont forget to install guest extensions - w/o it, seamless mode wont work. Note that seamless mode can be a b1tch to configure when you have multiple monitors. Jack up the Vbox's guest video RAM allocation to max allowed of 128MB.
This is also great for teaching classes, quick on-boarding of new dev team members etc - simply provide them with a Vbox .vdi file and they are ready to go.
- to get CDT to recognize C++11 syntax (auto, etc) you MUST go to :
Project Properties->C/C++ General->Preprocessor Include Paths, Macros->[Providers] tab->your Built-in Compiler Settings provider (toolchain dependent).
Click on "Workspace Settings" link which gets you to "Settings" property page, select [Discovery] tab and your provider again. There is "Command to get compiler specs", add "-std=c++0x" in there.
IT ####HASTOBE#### c++0x and ###NOT### c++11
Can not stress it enough. They will prolly fix it at some point, it gets way too many people.
- to get index to work, enable indexing in project properties.
- tell CDT to run make in "parallel" mode by specifying "-j" option in CDT. Might need to tinker with Makefile a bit, if you have tasks that need to finish in certain order. Allocate as many CPUs to the virtual box, as you can afford.
- Configure CDT to "auto-save on build" - this way, when you issue build command "Ctrl-B", it will auto save all the changes you made and then run the build. Code a lil', recompile/rerun, catch and fix errors. This cycle is really quick, the builds should be very quick (under a second for simple changes), you will see errors right in CDT and can navigate to their source code locations, with a simple click. Nirvana.
- For any serious coding, you MUST use some form of Version Control. SVN is nice, so are others. CDT offers full support for 100% integration. Check in/out, compare versions, rollback etc. Heaven. Tag and backup stuff religiously. Compress and encrypt the backups (openssl toolkit has the tools) and upload to a few cloud storages (Dropbox etc) for safety.
- Eclipse has excellent key-shortcut system. You can change the bindings to your liking - to mimic editors you're used to, perhaps. At the very least, locating definitions, references, type hierarchies, type outlines should never be more than a key press away, as are things like commenting blocks of code, moving lines around etc.
- Any serious coder must use tests. Google Test is highly recommended. Download and compile (cmake required) the google test library, search the web for examples. Edit your Makefile so that the tests are re-run upon every build. Should any error be discovered, you can see and navigate to them right in Eclipse. Priceless.
- Read google's own "C++ style guide". You can make Eclipse to help you enforce some of the guidelines through code templates. For example, when a new class is added, you can pre-generate "delete"d copy ctors etc.
### And lastly, some of the more subjective/opinionated suggestions:
- C++11 feels like almost a new language. If you're just starting to learn C++, I'd almost try to avoid getting polluted with advices that are 20 years old. Bjarne got his C++11 book out, get it. Jossutis has C++11 edition of his excellent guide. Lippman's 5th edition is C++11 aware. Sutter has excellent site with C++11 advice.
- Some of the most influential C++ authors, IMHO, are:
Bruce Eckels (especially for those with C background), TIC++, V1 and V2. This gent doesnt get nearly enough credit for his books, these are at the very top of my suggestion list.
Bjarne, Da 4th edition. "Design and evolution" explains why things are certain way
The last 4 are the voice of C++ community, driving force behind the evolution etc etc. Living Gods to many of us.
Current Time: Wed Sep 17 05:40:53 GMT 2014
Powered by FUDForum
. Page generated in 0.16986 seconds