Extag가 프로토타입 태그를 생성할 수 있도록 C 구문 수정 매크로를 실행 취소합니다.

Extag가 프로토타입 태그를 생성할 수 있도록 C 구문 수정 매크로를 실행 취소합니다.

tagsExtags를 사용하여 vim 파일을 성공적으로 만들 수 있습니다 (활기 넘치는 c 태그).

그러나 태그를 생성하면프로토타입으로 이동시스템 헤더가 다음 형식의 구문을 사용하여 매크로를 수정하기 때문에 함수의 기능이 작동하지 않습니다.

#define _EXFUN(name, proto)     name proto

예를 들어 string.h사용하십시오 .

char    *_EXFUN(strchr,(const char *, int));

_EXFUN대신 라벨을 생성합니다 strchr.

_EXFUN  /somedir/include/string.h   /^char  *_EXFUN(strchr,(const char *, int));$/;"    p

다음 명령을 사용하여 레이블을 만듭니다.

exctags -f tags.p --language-force=c --c-kinds=p file1 file2 ...

나는 extags 매뉴얼 페이지를 정독하고 -I매크로 확장에 영향을 주기 위해 다양한 옵션을 시도했지만 소용이 없었습니다. 이 문제를 해결한 사람이 있나요?

답변1

전처리된 파일을 실행 하고 전처리기의 주석( )을 보고 파일 에 줄 번호를 쓰도록 ectags요청합니다 ( 또는 ).--line-directives=yestags-n--excmd=numbers

cc -E prog.c >prog.p
ectags --line-directives=yes --language-force=c --c-kinds=p -n prog.p

예제 C 파일:

#define _EXFUN(name, proto)     name proto

char    *_EXFUN(strchr,(const char *, int));

결과 tags파일:

!_TAG_FILE_FORMAT       2       /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED       1       /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR    Darren Hiebert  /[email protected]/
!_TAG_PROGRAM_NAME      Exuberant Ctags //
!_TAG_PROGRAM_URL       http://ctags.sourceforge.net    /official site/
!_TAG_PROGRAM_VERSION   5.8     //
strchr  prog.c  3;"     p       file:

보시다시피 의 프로토타입은 strchr의 라인 3에 나타나는 것으로 나열됩니다 prog.c.

이것결점이는 전처리 매크로에 대한 태그 항목을 얻지 못하기 때문입니다.

ectags원본 파일과 함께 전처리된 파일을 실행하여 이 문제를 해결할 수 있습니다 .

ectags --line-directives=yes --language-force=c --c-kinds=pd -n -I _EXFUN prog.p prog.c

생산하다

[...]
_EXFUN  prog.c  1;"     d       file:
strchr  prog.c  3;"     p       file:

답변2

이 특정 매크로를 처리하려면 다음 옵션이 있습니다 --regex-<LANG>.

ctags --regex-c='/^[^#]*_EXFUN *\( *([^ ,]+),.*/\1/p/' ...

파일 을 생성합니다 tags.

_EXFUN  test.c     1;"     d       file:
strchr  test.c     /^char    *_EXFUN(strchr,(const char *, int));$/;"      p

관련 정보