code browsing, refactoring, auto completion in Emacs - c++

I recently switched to Emacs and still finding my way through it.
I code in C++ and was wondering what tools out there extend Emacs to support code browsing (finding a symbol etc), refactoring and code completion.
I have heard of:
cedet
etags
cscope
But I'm so confused about what I need. Some places say that cedet provides all of the functionality but other places say that I need to invoke etags for cedet to work properly.
Can someone clear this up for me? Do I need all of these tools?

Maybe you will find my article about Cedet useful. Cedet has support for etags, gtags, cscope and other tools.
But refactoring is missing. You may need to look into the Xrefactory tool (but it isn't free)

Cscope is very good as "find symbol" usage tool. It is very fast.
Etags will show you your class hierarchy and will help you to find method definition/declaration.
So these two tools are must have and they are independent.
Cedet. It is kind of replacement of these two tools above with additional features. So your choice either cscope/etags or cedet.

For refactoring, I started using emacs exclusively for this and related tasks after I read this article by emacs hacker Xah Lee.
For autocompletion, see this SO post. Personally, I've found yasnippet very helpful throughout the years.

gtags (http://www.gnu.org/software/global/) is also available and perhaps simpler to use.

Personally, I don't like cedet. It makes Emacs take an hour to load. The auto-complete feature has never worked quite right with me. I don't need its project-management nor its UML features.
The only thing I miss about it is the Emacs Code Browser, which is very useful but requires cedet
I would advice you to just use cscope and etags and see how you like them. You can install cedet later once you're more familiar with emacs.

I wrote a blog article about using Global/gtags and Speedbar for code browsing you might find useful... (I also thought CEDET was a bit slow... and extremely complicated to set up =)

Related

Call Hierarchy Eclipse feature in Vim?

I am considering migrating from eclipse to vim for c++ development- I've recently "rediscovered" Vim, and finally went beyond the basics. I'm loving it, but there are still a few features that I use constantly in Eclipse that I'd also like to see in Vim.
One of them is call hierarchy. It's extremely helpful to know where a particular function/method is called throughout a project, and having an overview at a glance. Is there a similar plugin for that in Vim? Perhaps a combination of plugins/commands that are equivalent?
https://stackoverflow.com/questions/149558/recommended-vim-plugins-for-c-coding
A combination of the cscope and taglist plugins (linked from above) should give you what you want. Possibly cctree. All of these have problems with templates, however.
Also check out eclim
Eclipse has a built-in C++ parser that runs in the background and fully parses and semantically analyzes C++ code. This is what allows it to provide code completion, call hierarchy, refactoring and similar features.
I'm not aware of anything like that being available for vim. If someone knows something like that, I would be interested too.

boost doxygen documentation

I have been trying to generate doxygen documentation for boost, as a way to browse source tree and have man documentation.
However, doxygen has been running for past week or so on IBM power5, and I have no idea how much longer (right now I am on boost_1_43_0/boost/mpl/).
Is there prebuilt doxygen documentation, if not, is there any way to speed up documentation generation without losing cross-referencing in code browser?
I have been using older documentation located on tena-sda, but that is quite old.
thank you
I agree with you. However, doxygen cannot parse the complexity of C++ that Boost utilizes. Best bet is for you to grock (search) the source with a powerful IDE.
Even if it was working using doxygen to browse a source code is not really relevant. Here are two alternatives that I use daily :
grep is your friend ! It is very efficient and fast to find what you want in a source code, even if this one is large
Make development with an IDE that support live parsing like NetBeans, then you will have cross-references inside your whole code, even across libraries (like Boost) that it uses, inside the editor itself.

Doxygen integration with (unmanaged) Visual C++ 2005

We are slowly moving towards better-standardized commenting in a large C++ project, introducing Doxygen. I personally find it a pain typing in comments, especially since Java IDEs are so good at automating this.
So I wondered what tools there might be? A search turned up DoxyComment which looks quite nice, is this the best/standard tool or are there others worth a look too?
Atomineer is a tool that I and a few others have been using for documenting unmanaged C++ code with Doxygen markup. It's not free, but it is cheap, and may be worth a try:
http://www.atomineerutils.com/products.php
If typing the meta-comments which are instructions to doxygen is a significant part of your comment-writing effort, you're doing it wrong.
Comment should not include things which can be automatically determined by a tool, any programmer will determine just as much (or more) information from e.g. parameter names than any tool.
Another way to look at this is that doxygen already does an excellent job of presenting what can be automatically determined. You don't need to write: "B::B constructs a B object", since doxygen is going to sort it into the constructors section of the documentation automatically.
Focus on what's non-obvious, and take time to think about what you're writing.
Normally many functions and variables will have no need for an individual comment, since either the name is descriptive enough, or they are better explained in a class-level comment describing how multiple members interact.

What is a good way to edit C++ on Mac OS X?

I am a first year Comp. Sci. student and am looking for the best way to develop C++ on a Mac. I have Xcode and Textmate.
What are the benefits/negatives of each? Are there any better ones?
I am not a fan of having to use a whole project to run programs with Xcode. Is this the only way to do it, or am I mistaken?
Also, is there a way to change the default text that is included in a .cpp file in xcode?
What is a good way to edit C++ on Mac OS X?
With your head.
Try both. Text editors are a matter of personal taste. See the flames over vim vs. emacs that make the Sun look pale.
The only one that can tell you what is the best text editor for you, is you.
http://code.google.com/p/macvim/
I would dig in and learn vim (or emacs if you really want to).
EDIT: You've got 4+ years ahead of you in CS. I really would suggest learning vim or emacs especially when you are still in university.
With Xcode you can edit each file separately, without needing them to belong to a project. Also, you can look in /Developer/Library/Xcode/File Templates for the templates used by Xcode; feel free to take a whack at them as you find suitable.
I'm a huge fan of textmate. It gives you a lot of power but doesn't get in your way. You could also try Eclipse for C/C++
I almost exclusively use Textmate, but to be fair the decision to switch to Textmate (coming from codewarrior in OS 9 days), was mainly because the XCode editor (then named ProjectBuilder) was annoyingly slow at editing larger files.
I'm sure that changed a lot over the years, but I see no reason to switch so I don't.
That said, one thing where XCode really outshines Textmate is the integration of a debugger, when you're just starting to learn, I think having an integrated debugger will help you quickly understand what's going on with your code, and will be a great advantage...
If you've got Textmate, just try em both for a few months, you're a student anyway, you should have plenty of time
Netbeans is free, has great auto-completion for C++, Java and others. It's also cross-platform.
http://www.netbeans.org/downloads/
I am not a fan of having to use a whole project to run programs with Xcode. Is this the only way to do it, or am I mistaken?
Because MacOS X is built on top of Unix you have many development tools available to you that lie outside of XCode. Most notably with a good Terminal application you can develop directly with gcc, bypassing XCode altogether. In that case I'd recommend finding a source editor you're comfortable with, such as TextMate or one of the others recommended here. Using gcc directly gives you the rapid turnaround with little overhead you seem to be looking for.
I'm a huge fan of emacs, because:
1) It's extensible. Thousands of languages are supported, you have modes for editing XML, HTML, etc.
2) It's highly configurable. You can set your own key bindings, change indentation, etc.
3) It's powerful. It integrates easily with compilers, debuggers, it makes text editing really quick.
You can check vi, textmate or xcode too. They're all great editors. It all comes to which one works better for you.
I quite like Xcode. I'm not sure why you ruled it out. It's really not that complicated.
I recently used SublimeText it is nice and fast. Give it a try.

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up.
I am basically looking for something to take code written by two people, and clean it up to a standardized style. Does such an app exist?
Thanks a bunch!
Artistic Style
is a source code indenter, formatter,
and beautifier for the C, C++, C# and
Java programming languages.
GC Great Code
is a well known C/C++ source code
beautifier.
Of course I find an answer to my own question moments later. What luck, I probably spent an hour searching earlier.
Should anyone be looking for the same thing, check out Uncrustify at http://uncrustify.sourceforge.net/
If you're using Visual Studio then you could take a look at StyleManager*. It's a VS add-in that makes it easy to set up formatting styles and apply them to code whenever you need to. It's a popular choice with VS users, and in particular was used by the DirectX SDK team to tidy up their sample code.
*Huge disclaimer: I'm one of the authors of this software, so apologies for the shameless plug!
You can tidy your code online, with this website:
https://codebeautify.org/cpp-formatter-beautifier
https://codebeautify.org/cpp-formatter-beautifier