I think you might solve your problem with the Omni Completion function working with a program like exuberant ctags.
The idea is to generate a tags file containing the different classes, constants, fields, etc... of your code and letting Vim use this list to generate the autocomplete suggestions.
To do so:
Install exuberant ctags: $ sudo apt-get install exuberant-ctags
(or the equivalent command for your distribution).
Generate the tags file: $ ctags *.c *.h
a file named tags
shoud be generated on your folder.
Let Vim knows where is your tags file: :tags=./tags,tags
with these settings Vim looks for a tags file in the directory of the current file
and in the working directory. Note that you can use :set tags?
to check your current configuration.
Call the Tag Completion: Now when writing a word and hitting <C-x><C-]>
Vim will use this tags list to autocomplete your word.
Bonus: As you might have noticed your tags file will not update automatically, which means that when you write new prototypes the tag completion will not suggest them. If your codebase isn't too big you could put this line in your .vimrc
:
:autocmd BufWritePost * call system("ctags -R")
That will simply regenerate the tags file each time you save a file. It is important to note that if your codebase is important, this trick might considerably slow down your workflow.
void PrintOneNode(){}
becomes the declaration and definition, it is syntactically valid. So, forvim
to "guess" that it was wrong, it would have to keep a list of functions declared/defined and look for "similar" names. The best that I can think of is to check the declaration when you're defining, using ctags (or similar), or use some completion tool so that you can pick the name from a list.-Wmissing-prototypes
will tell you if a function is missing a prototype.