News for hackers. Stuff that matters.
Re:What I Wish I Had Known About Developing C/C++ From Linux... by Periodic on Tuesday April 21, 2009 @07:49PM (#573235)
When I started developing in C in Vim there are two things I've gotten used to that I can't live without now: ctags and auto-complete (they help with eachother).

Ctags is great, especially for navigating someone else's code. What does this function do? Just ctrl-] and suddenly I'm at its definition. Something in there I don't recognize, same thing. Ctrl-t to go back up the tag stack. Ive become so used to navigating my code this way I have trouble without it.

Completion is just the way that Vim will give you completion matches in insert mode if you hit ctrl-n or ctrl-p. With C it's very smart about it and will automatically search included files. It's great for not having to worry about exact spellings on things. If you really like this sort of stuff there are a few plugins that do Textmate-like snippets.

Re:What I Wish I Had Known About Developing C/C++ From Linux... by visitor4rmindia on Wednesday April 22, 2009 @12:58AM (#573541)
If you like CTags give CScope a try. It's sort of like CTags on steriods. Also Vim can work with a combination of both (it loads both cTAGS and cscope.in) so you don't loose any functionality.

The biggest plus you get when using CScope is the ability to do a "reference" search. You can find all references to a given symbol in your project quickly and easily which I find invaluable for refactoring (what's going to be affected when I change this?).

Re:What I Wish I Had Known About Developing C/C++ From Linux... by barrkel on Tuesday April 21, 2009 @07:57PM (#573246)
Of course, if you use an IDE, it can do all of this for you and much more, and more accurately than ctags.
Re:What I Wish I Had Known About Developing C/C++ From Linux... by silentbicycle on Tuesday April 21, 2009 @09:13PM (#573318)
Of course, it's easier to write a program that generates tags for a new language than to build an IDE around it.
Re:What I Wish I Had Known About Developing C/C++ From Linux... by ori_b on Tuesday April 21, 2009 @10:13PM (#573396)
Ctags is just as accurate at scanning C declarations as an IDE, and with a bit of vim magic, it even auto-updates when you save files.

One thing to realize is that vim IS an IDE of sorts. Only, it's far more extensible for the same effort. (although, from my brief forays with emacs, emacs certainly beats vim for extensibility)

Re:What I Wish I Had Known About Developing C/C++ From Linux... by ramchip on Tuesday April 21, 2009 @10:58PM (#573430)
Emacs also supports ctags. I didn't find it very useful with C++ though, which is my usual language, since it didn't autocomplete member functions - I think it's supposed to work, though I couldn't be pushed to tweak it.

Cscope, as commented on the article's website, sounds quite interesting too.

Re:What I Wish I Had Known About Developing C/C++ From Linux... by kingkongrevenge on Tuesday April 21, 2009 @11:37PM (#573467)
ctags on C++:

ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .

Re:What I Wish I Had Known About Developing C/C++ From Linux... by ori_b on Tuesday April 21, 2009 @11:41PM (#573473)
ctags takes an environment variable for it's options, too:

    export CTAGS='-R --c++-kinds=+p --fields=+iaS --extra=+q'
and then you can just run 'ctags .'
Re:What I Wish I Had Known About Developing C/C++ From Linux... by barrkel on Tuesday April 21, 2009 @11:00PM (#573436)
What about conditionally compiled code, based on preprocessor definitions? And what happens when you change one of those definitions in the editor? Visual Studio, for example, will re-scan the source in the background.

And what about tokens created using the token pasting operator ## from include files that are included multiple times (e.g. code generation hackery)? Visual Studio will at least locate the include file which introduced the token, and of course will be able to complete on the token, aware of its type etc.