Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Neslepaks
Sep 3, 2003

quote:

code:
char* buf = (char*)malloc(fileSize);
code:
str = (char *)calloc(strlen(visitIdent(_p_->u.stm_.ident_))+2, sizeof(char));

Don't do these casts when writing C. void pointers are always implicitly castable to other pointers, all you'll achieve is to hide warnings you'd want to see (like if you forgot to include the prototype for malloc, or there's a more serious type mismatch).

Adbot
ADBOT LOVES YOU

Neslepaks
Sep 3, 2003

ShinAli posted:

Not a C question really but I wanna know how to set up vim to be a pretty good IDE for C programming.

I saw a website out there describing out to set up vim for python, and had all these neat things like a debugger, code completion, COLOR, and so forth. I'm starting to like vim (even though I don't have a handle on all the commands and stuff yet), and since I'm going to be using vim for the entire semester, I'd like to configure it a bit for C.

You guys got anything?

These are my C specific settings:

autocmd BufRead,BufNewFile *.c,*.h,*.cc,*.cxx,*.hxx set cindent formatoptions=corq cinoptions=:0(0 textwidth=72 sm comments=sr:/*,rmb:*,exr:*/

That does auto-indentation with lining up the way I like it, paren/brace/bracket-matching, automatic comment formatting and wrapping (ie, you write /*<enter>, it fills in " * " for you, etc). Colors is just :syntax on.

I don't use make integration and that stuff much, but see :help make.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply