ctags多线C函数原型

有没有办法让ctags在C中处理多行函数原型?

我已经四处搜索了--fields=+S应该做多线原型,但我不能让它工作:

 ctags -x --c-kinds=pf --fields=+S file 

文件:

 int foo(int x, int y ); 

ctags只返回:

 foo(int 

(注意,返回类型也缺失)

最终我想获得类似的输出

 int foo(int x, int y); 

要么

 int foo(int x, int y 

--fields=+S不是正确的方法? 我缺少哪些ctags字段? 一般的指针?

如果没有办法在ctags中做任何推荐的程序? (我目前正在寻找unrustify)

我的代码遇到了同样的问题但我无法修改它。 当我使用–fields = + S参数时,它似乎工作,因为我在标记文件中得到一个额外的行。 signature:part包含函数的所有参数。

CopyToTX26 D:\ BiseL \ My Dropbox \ Work \ 0_BSW \ PKG_CMD \ Memory.c / ^ void CopyToTX26(uint16 memory_ID,uint32 ** pt_data_address,uint32 nb_recover,$ /;“f signature 🙁 uint16 memory_ID,uint32 ** pt_data_address, uint32 nb_recover,uint32 * nb_copied,uint32 max_length)

我无法找到任何ctags,所以我写了一个python脚本来重新安排我的文件,以便ctags可以捕获原型。

注意:我的代码有注释,因此大部分都需要删除它们(否则它们会妨碍ctags)。

操作按此顺序进行:

 # concat to one line file_str = '' for line in read_from.readlines(): file_str += line # remove all /* */ comments file_str = re.sub('/\*(.|[\r\n])*?\*/', '', file_str) # remove '//' comments file_str = re.sub('//.*', '', file_str) # split on '\n' file_as_list = file_str.splitlines(True) # strip everything for index in range(len(file_as_list)): file_as_list[index] = file_as_list[index].strip() # add in newlines where appropriate for line in file_as_list: # if the line ends in ';' or '}' if line.endswith(';') or line.endswith('}'): # append a newline to the stripped line write_to.write(line.strip() + '\n') else: # append a space to the stripped line write_to.write(line.strip() + ' ') 

–_ xformat选项可以帮助您。

 [jet@localhost ~]$ cat /tmp/foo.h int foo(int x, int y ); [jet@localhost ~]$ ~/var/ctags/ctags -x --c-kinds=pf --_xformat="%-16N %4n %-16F %C %S" /tmp/foo.h foo 2 /tmp/foo.h foo(int (int x,int y) 

您可以使用简单的filter删除不需要的换行符,例如

  tr '\n' ' ' | sed 's/\([{};]\)/\1\n/g'