Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate ctags file for C or C++ files and its depedencies (included header files). This could avoid you to always generate a huge tags file.
#!/bin/sh
# https://www.topbug.net/blog/2012/03/17/generate-ctags-files-for-c-slash-c-plus-plus-source-files-and-all-of-their-included-header-files/
# ./ctags_with_dep.sh file1.c file2.c ... to generate a tags file for these files.
gcc -M "$@" | sed -e 's/[\\ ]/\n/g' | \
sed -e '/^$/d' -e '/\.o:[ \t]*$/d' | \
ctags -L - --c++-kinds=+p --fields=+iaS --extra=+q
@osirisgothra

This comment has been minimized.

Copy link

osirisgothra commented Jun 3, 2015

awesome

@dragonly

This comment has been minimized.

Copy link

dragonly commented Jul 23, 2016

非常棒,不过还要手动去Makefile里面找IncludeDir之类的,虽然还好

@squm

This comment has been minimized.

Copy link

squm commented Jan 2, 2017

tr '\\ ' '\n'

@ohhmm

This comment has been minimized.

Copy link

ohhmm commented Jun 23, 2017

why have not gcc an option to generate tags file?

@ohhmm

This comment has been minimized.

Copy link

ohhmm commented Jun 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment