나의 리눅스 커널 개발 프로젝트에서 IDE로 Emacs를 사용하려고한다. 그래서 CEDET와 GNU Global (gtags)을 문제없이 설치했습니다.C prepetcessor가 Cedet/Semantic에 의해 고려되지 않는다.
내 Linux 커널 소스 폴더에 속한 C 소스 코드를 열면 Linux 프로젝트가 자동으로 감지됩니다. 함수, 변수, 헤더 및 기타 키워드가 올바르게 강조 표시됩니다.
~/.emacs 파일을 통해 의미 론적 코드 완성과 인텔리 센스를 구성했습니다. 그래서 C-를 누르면 코드 완성 메뉴가 나타나고 필요한 것을 선택할 수 있습니다.
전 처리기 정의를 사용할 때 인텔리 센스 시스템이 현재 위치의 메뉴를 표시하지만 호출 할 때 올바른 것을 감지하지 못합니다 (C-). emacs를 닫고 다시 시작해도 동일한 동작이 재현됩니다.
테스트 코드는 다음과 같습니다
// ----------------------------------- -------------------------------------------------- ---
typedef struct
{
int p1;
#ifdef __KERNEL__
int p2;
#endif
#ifdef USE1
char p3;
#endif
#ifdef __LINUX_ARM_ARCH__
int p4;
#endif
}OBJ;
OBJ g_obj;
// -------------------------------------- -------------------------------------------------- 이미 정의되어
커널, USE1 및 LINUX_ARM_ARCH은 다음과 같습니다
.emacs 파일에서 커널 프로젝트를 빌드 할 때 GCC 크로스 컴파일러 (ARM 용 GCC)에 필요한 모든 필수 항목과 정의를 추가했습니다.
또한 GCC 시스템 대신에 GCC 크로스 컴파일러 명령 행을 사용하여 정확하게 사전 처리하도록 시도했지만 그 방법을 찾지 못했습니다.
"M-x semantic-c-describe-environment"명령은 오른쪽 포함 경로를 표시하고 (.emacs로 설정)을 정의합니다. 그러나 GCC가 정의하는 시스템도 나열되어 있습니다.
.emacs 파일과 소프트웨어 버전은 아래와 같습니다.
어떤 도움이나 표시는 환영 :) 안부
############# Software versions #############
- Emacs (23.2.1)
- Ubuntu machine (natty, 11.04)
- Cedet 1.0 (from http://cedet.sourceforge.net/)
############# .emacs #############
;load CEDET
(load-file "~/Documents/my_emacs/cedet-1.0/common/cedet.el")
(require 'ede)
(global-ede-mode t)
; turn on which-func support (plus all other code helpers)
(semantic-load-enable-gaudy-code-helpers)
(semantic-load-enable-excessive-code-helpers)
; turn on all "useful" features
(setq semantic-load-turn-useful-things-on t)
(setq-mode-local c-mode
semanticdb-find-default-throttle
'(project unloaded system recursive))
;init names completion, and displaying of information for tags & classes
(require 'semantic-ia)
;preprocessing of source code
(require 'semantic-c)
(semantic-reset-system-include 'c-mode)
(semantic-reset-system-include 'c++-mode)
(semantic-add-system-include "/home/abdellatif/toolchain/arm-eabi-4.4.3/lib/gcc/arm-eabi/4.4.3/include" 'c-mode)
(semantic-add-system-include "/home/abdellatif/kernel/arch/arm/include" 'c-mode)
(semantic-add-system-include "/home/abdellatif/kernel/include" 'c-mode)
(semantic-add-system-include "/home/abdellatif/kernel/arch/arm/mach-omap2/include" 'c-mode)
(semantic-add-system-include "/home/abdellatif/kernel/arch/arm/plat-omap/include" 'c-mode)
(add-to-list 'semantic-lex-c-preprocessor-symbol-file "/home/abdellatif/kernel/include/generated/autoconf.h")
(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("__KERNEL__" . ""))
(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("__LINUX_ARM_ARCH__" . "7"))
(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("KBUILD_STR(s)" . "#s"))
(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("KBUILD_BASENAME" . "KBUILD_STR(main)"))
(add-to-list 'semantic-lex-c-preprocessor-symbol-map '("KBUILD_MODNAME" . "KBUILD_STR(main)"))
;semantic integration with imenu (display of a menu with a list of functions, variables, and other tags)
(defun my-semantic-hook()
(imenu-add-to-menubar "TAGS"))
(add-hook 'semantic-init-hooks 'my-semantic-hook)
;names completion (semantic commands)
(defun my-cedet-hook()
(local-set-key [(control return)] 'semantic-ia-complete-symbol)
(local-set-key "\C-x " 'semantic-ia-complete-symbol-menu)
(local-set-key "\C-x\r" 'gtags-find-tag-from-here))
(add-hook 'c-mode-common-hook 'my-cedet-hook)
;navigating in source code
(semantic-mru-bookmark-mode 1)
;tell semantic to store its tags database between sessions here
(require 'semanticdb)
(setq-default semanticdb-default-save-directory "~/.semantic.cache")
(setq-default semanticdb-default-system-save-directory "~/.semantic.cache")
;allow Semanticdb use databases generated by global(gtags)
(require 'semanticdb-global)
(semanticdb-enable-gnu-global-databases 'c-mode)
감사합니다. 나는 시도 할 것이다 :) –