0

I am developing an IDE which supports c programming language.

i want to implement a autocomplete feature by pressing ctrl+space.

For that i need to extract all function prototypes from header files.

Please suggest me the way

Thanks suchetan

  • You might want to look at `ctags`. See, for example, [Autocomplete libraries for Java, C, PHP?](https://stackoverflow.com/q/1697432/608639), [Is there an alternative to ctags that works better?](https://stackoverflow.com/q/7748454/608639), [How does Geany auto-completion work?](https://stackoverflow.com/q/7490915/608639), [Autocompletion in Vim](https://stackoverflow.com/q/1115876/608639) and friends. – jww Sep 18 '19 at 05:49
  • Please clarify whether you intend to implement a C parser. – Yunnosch Sep 18 '19 at 06:11
  • This forum is dedicated to answer specific programming questions, not to do your work completely. – Guillaume Petitjean Sep 18 '19 at 06:26
  • not my work @GuillaumePetitjean. i want idea or way to get the thing. because it may useful for many developers who r working on this kind of feature. eclipse have that feature. code assist and visual studio with intelisense. forget about it. In a system there will be many c libraries header files. i want to know that function prototypes many people need this solution – Suchetan B Sep 18 '19 at 07:12
  • @Yunnosch parser to implement autocomplete feature like eclipse in my editor. – Suchetan B Sep 18 '19 at 07:16

2 Answers2

1

As @jww said in a comment: have a look at ctags or the more elaborate: cscope, both of which are usable for completion in vim.

Specifically have a look at cscope's scanner which uses flex to create a scanner that identifies token types.

marcolz
  • 2,880
  • 2
  • 23
  • 28
  • Please don't just post some tool or library as an answer. At least demonstrate [how it solves the problem](http://meta.stackoverflow.com/a/251605) in the answer itself. – Yunnosch Sep 18 '19 at 15:53
  • You might of course notice that you can't, which illustrates that the question as it is needs clarification or is asking for library recommendation or is too broad. All of that means the question is off-topic and cannot be answered to make a useful Q/A pair. – Yunnosch Sep 18 '19 at 15:55
0

shell script to extract all functions except constructor and destructor from XYZ.cpp:

ctags -x XYZ.cpp | grep function | awk '{print $6}' | grep "XYZ" | awk -F'::' '{print $2}' | awk -F'(' '{print $1}'
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – shamnad sherief Jan 24 '23 at 19:01