Last active
June 13, 2024 15:47
-
-
Save xuhdev/1729992 to your computer and use it in GitHub Desktop.
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.
why have not gcc an option to generate tags file?
This won't work on MacOS since sed on MacOS does not interpret '\n' as a newline.
So, another way of doing this would be:
gcc -M $* | tr '\\ ' '\n' | sed -e '/^$/d' -e '/\.o:[ \t]*$/d' | \
ctags -L - --c++-kinds=+p --fields=+iaS --extra=+q
you could also replace the sed with gsed, and another hacks. but the above works for me. Thanks for the idea!
I like it.
Add this directly into my makefile.
@$(CC) -M $(CFLAGS) $(SRC) | sed -e 's/[\\ ]/\n/g' | \
sed -e '/^$$/d' -e '/\.o:[ \t]*$$/d' | \
ctags -L - --c-kinds=+p --fields=+iaSl --extra=+q --langmap=c:.c.h
This won't work on MacOS since sed on MacOS does not interpret '\n' as a newline. So, another way of doing this would be:
gcc -M $* | tr '\\ ' '\n' | sed -e '/^$/d' -e '/\.o:[ \t]*$/d' | \ ctags -L - --c++-kinds=+p --fields=+iaS --extra=+qyou could also replace the sed with gsed, and another hacks. but the above works for me. Thanks for the idea!
Well, it works just fine for me as of February 2023 on an Intel Mac.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tr '\\ ' '\n'