[완료] cscope, ctag - 헤더파일에 define 된 (인라인) 맴버 함수 어떻게 찾을 수 있을까요?

oosap의 이미지

vim 을 사용해서 C++ 소스코드 브라우징시에 한가지 불편한 점이 있습니다.

ctrl+]

를 사용해서 함수의 define 을 찾고자 할 때 일반적인 함수들 그리고 클래스 맴버 함수들은 잘 찾아집니다. .cpp 파일에 define 된 것들 말입니다. 그런데 .h 파일에 define 된 클래스 맴버함수들은 찾아지지가 않습니다. 이제 저는 요령이 생겨서 이렇게 안찾아지는 것들은 분명 헤더파일에 있다고 알게 되어서 헤더파일을 열어서 찾습니다. 그럼 100프로 헤더파일에 있습니다.

ctags --langmap=C++:.inc --c++-kinds=+p --fields=+iaS --extra=+fq --sort=foldcase -R .

#!/bin/sh
 
rm -rf cscope.files cscope.out
 
find `pwd` \( -name '*.c' -o -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.hpp' -o -name '*.java' -o -name '*.s' -o -name '*.S' -o -name '*.inc' \) -print > cscope.files
 
cscope -i cscope.files

제가 tags 파일과 cscope.out 파일을 만들 때는 위와 같이 만듧니다.
제가 뭘 잘못한 걸까요? 혹시 제 문제를 해결할 수 있는 방법이 있을까요?

헤더파일에 define 된 클래스 멤버함수도 쉽게 찾고 싶습니다.

oosap의 이미지

물론 cs find e 를 통해 grep 하는 방법은 가능합니다. 하지만 이는 제가 원하는 방법이 아닙니다.

ctrl+]

를 통해 일관되게 .cpp 파일에 정의된 함수처럼 .h 파일에 정의된 함수도 찾을 수 있는 방법이 궁금합니다.

Thanks for being one of those who care for people and mankind.
I'd like to be one of those as well.

qiiiiiiiip의 이미지

제가 간단히 테스트 해보았는데 잘 찾아지던데요..

ctrl+] 로 가는 것은 ctags에 의한 것입니다.
tag 파일이 잘 안만들어진것 같네요..

tag 파일에서 해당 함수이름을 찾아보시죠.. 어떻게 되어있는지..

안되는 소스 및 tag 파일을 올려 보시는 것도..

아.. 저는 그냥 ctags -R 로합니다...ㅎㅎ

--

vim옵션에 따라서 ctrl+]가 cscope db를 먼저 참조하기도 하네요...

저는 cscope만 사용하는 경우에도 말씀하신 방법으로 잘 됩니다..

ctags나 cscope나 하나씩 사용하시면서 어느부분이 문제인지 찾아보심이..

qiiiiiiiip의 이미지

사용하신 ctags 옵션 중

--langmap=C++:.inc

이 문제가 되네요..
어떤 의도로 넣으셨는지 모르겠으나, 빼시든가,

--langmap=C++:+.inc

로 고치시든가 하면 될것 같습니다...

oosap의 이미지

말씀하신대로 하니까 잘 되는군요..

해당 옵션을 넣은 이유는 제가 보고 있는 코드가 C++ 코드를 .inc 라는 확장자이름으로 일부 가지고 있기 때문입니다.
위 옵션을 넣어줘야 .inc 파일도 C++ 파일로 간주를 하고 태그 생성을 할 때 포함하는 것입니다.

이 내용은 인터넷에서 찾아서 넣었던 것인대 복사붙여넣기 하다가 확인 안했던 것이 이렇게 문제로 나타났던 것 같습니다.
알려주셔서 감사합니다. ^^;

참고 : man ctags
to specify that only files with extensions of .c and .x are to be treated as C language files,
use "--langmap=c:.c.x"; to also add files with extensions of .j as Java language files, specify "--langmap=c:.c.x,java:+.j".

cscope 로는 이런 인라인 함수가 안찾아지는 군요.. 원래그런건지...

암튼 감사합니다..

Thanks for being one of those who care for people and mankind.
I'd like to be one of those as well.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.