Thread: [CEDET-devel] How to say to EDE to use c++ header file?
Brought to you by:
zappo
From: Denis S. <ope...@gm...> - 2009-07-08 13:15:06
Attachments:
test.tar.gz
|
Hi, All! I have pch.hxx where i put all useful #include-s, for example <vector>. It includes by adding -ipch.hxx option for gcc, not by #include. When i try autocomplete std::vect in somewhere in a cxx file i get this: Cannot find types for `"std"' But it works when i explicitly include <vector> in the cxx file. Is there any way to say to EDE to use that header? I attach a tarball with an example, look a file src/main.cxx. P.S. Sorry if my English is horrible. (: -- Sukhonin Denis |
From: Eric M. L. <er...@si...> - 2009-07-09 01:36:29
|
On Wed, 2009-07-08 at 17:14 +0400, Denis Sukhonin wrote: > Hi, All! > > I have pch.hxx where i put all useful #include-s, for example <vector>. > It includes by adding -ipch.hxx option for gcc, not by #include. > > When i try autocomplete std::vect in somewhere in a cxx file i get this: > Cannot find types for `"std"' > But it works when i explicitly include <vector> in the cxx file. > > Is there any way to say to EDE to use that header? > > I attach a tarball with an example, look a file src/main.cxx. Hi, I am not familiar with this gcc option, and as such have never thought to try to add such a feature. Here is a patch which I have not tested: Index: semanticdb-find.el =================================================================== RCS file: /cvsroot/cedet/cedet/semantic/semanticdb-find.el,v retrieving revision 1.77 diff -b -u -r1.77 semanticdb-find.el --- semanticdb-find.el 16 May 2009 11:45:58 -0000 1.77 +++ semanticdb-find.el 9 Jul 2009 01:31:52 -0000 @@ -421,6 +421,9 @@ and TAG is a clone of the include tag that was found.") (make-variable-buffer-local 'semanticdb-find-scanned-include-tags) +(defvar semanticdb-implied-include-tags nil + "Include tags implied for all files of a given mode.") + (defun semanticdb-find-translate-path-includes--internal (path) "Internal implementation of `semanticdb-find-translate-path-includes-default'. This routine does not depend on the cache, but will always derive @@ -435,7 +438,9 @@ nexttable) (cond ((null path) (semantic-refresh-tags-safe) - (setq includetags (semantic-find-tags-included (current-buffer)) + (setq includetags (append + (semantic-find-tags-included (current-buffer)) + semanticdb-implied-include-tags) curtable semanticdb-current-table incfname (buffer-file-name)) ) ---------- You could then write something like: (defvar-mode-local c++-mode semanticdb-implied-include-tags (list (semantic-tag-include "ipch.hxx"))) to make your case work. If this concept works, for your case, I'll see what sorts of things I can do in EDE for this situation. Eric |
From: Denis S. <ope...@gm...> - 2009-07-10 06:08:58
|
It's works after evaluating (setf semanticdb-implied-include-tags (semantic-find-tags-included (ede-expand-filename (ede-toplevel) "pch.hxx"))) in buffer with cxx-file. Thanks. But now I can't get autocomplete for this simple case: std::vector<int> v; v.[M-x semantic-ia-complete-symbol-menu] I get this: semantic-analyze-possible-completions-default: Cannot find types for `std::vector v' Aurgh! The same when I write just vector without namespace. I have recreated semanticdb-default-save-directory and nothing changes. Note, std::vect[M-x semantic-ia-complete-symbol-menu] works and finds std::vector{}. I use latest emacs and cedet from CVS. My configuration: (load-file "~/.emacs.d/elisp/cedet/common/cedet.el") (setq semantic-load-turn-useful-things-on t) (semantic-load-enable-excessive-code-helpers) ;;(semantic-load-enable-semantic-debugging-helpers) (setq senator-minor-mode-name "SN" semantic-imenu-auto-rebuild-directory-indexes nil) (global-srecode-minor-mode 1) (global-semantic-mru-bookmark-mode 1) (global-semantic-folding-mode 1) ; hide and show blocks (global-semantic-idle-tag-highlight-mode 1) (require 'semantic-decorate-include) (require 'semantic-ia) (require 'semantic-tag) (setq-mode-local c-mode semanticdb-find-default-throttle '(project unloaded system recursive)) (setq-mode-local c++-mode semanticdb-find-default-throttle '(project unloaded system recursive)) (setq-mode-local erlang-mode semanticdb-find-default-throttle '(project unloaded system recursive)) ;; Enable SemanticDB. (require 'semanticdb) (require 'semantic-gcc) (semantic-gcc-setup) (global-semanticdb-minor-mode 1) (setq semanticdb-default-save-directory "~/.tmp/semanticdb") (when (not (file-exists-p semanticdb-default-save-directory)) (make-directory semanticdb-default-save-directory)) (setq boost-dir "/usr/include/boost") (when (file-exists-p boost-dir) (add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat boost-dir "/boost/config.hpp"))) ;; EAssist. (when (require-maybe 'eassist) (setq eassist-header-switches (append eassist-header-switches '(("hxx" "cxx") ("cxx" "hxx") ("H" "cc") ("cc" "H")) ))) ;; SpeedBar. (require 'semantic-sb) ;; EDE. (require 'semantic-lex-spp) (global-ede-mode 1) ;; Enable Imenu. (add-hook 'semantic-init-hooks (lambda () (imenu-add-to-menubar "TAGS"))) (defun negval:cedet-hook nil (local-set-key (kbd "C-<return>") 'semantic-ia-complete-symbol) (local-set-key (kbd "C-c ?") 'semantic-ia-complete-symbol-menu) (local-set-key (kbd "C-c >") 'semantic-complete-analyze-inline) (local-set-key (kbd "C-c =") 'semantic-decoration-include-visit) (local-set-key (kbd "C-c p") 'semantic-analyze-proto-impl-toggle) (local-set-key (kbd "C-c j") 'semantic-ia-fast-jump) (local-set-key (kbd "C-c q") 'semantic-ia-show-doc) (local-set-key (kbd "C-c s") 'semantic-ia-show-summary) (local-set-key (kbd "C-c h") 'eassist-switch-h-cpp)) (add-hook 'c-mode-common-hook 'negval:cedet-hook) (add-hook 'emacs-lisp-mode-hook 'negval:cedet-hook) (add-hook 'erlang-mode-hook 'negval:cedet-hook) (custom-set-variables '(semantic-idle-scheduler-work-idle-time 10) '(semantic-self-insert-show-completion-function (lambda nil (semantic-ia-complete-symbol-menu (point)))) '(global-semantic-tag-folding-mode t nil (semantic-util-modes))) Eric M. Ludlam wrote: > On Wed, 2009-07-08 at 17:14 +0400, Denis Sukhonin wrote: > >> Hi, All! >> >> I have pch.hxx where i put all useful #include-s, for example <vector>. >> It includes by adding -ipch.hxx option for gcc, not by #include. >> >> When i try autocomplete std::vect in somewhere in a cxx file i get this: >> Cannot find types for `"std"' >> But it works when i explicitly include <vector> in the cxx file. >> >> Is there any way to say to EDE to use that header? >> >> I attach a tarball with an example, look a file src/main.cxx. >> > > Hi, > I am not familiar with this gcc option, and as such have never thought > to try to add such a feature. > > Here is a patch which I have not tested: > > Index: semanticdb-find.el > =================================================================== > RCS file: /cvsroot/cedet/cedet/semantic/semanticdb-find.el,v > retrieving revision 1.77 > diff -b -u -r1.77 semanticdb-find.el > --- semanticdb-find.el 16 May 2009 11:45:58 -0000 1.77 > +++ semanticdb-find.el 9 Jul 2009 01:31:52 -0000 > @@ -421,6 +421,9 @@ > and TAG is a clone of the include tag that was found.") > (make-variable-buffer-local 'semanticdb-find-scanned-include-tags) > > +(defvar semanticdb-implied-include-tags nil > + "Include tags implied for all files of a given mode.") > + > (defun semanticdb-find-translate-path-includes--internal (path) > "Internal implementation of > `semanticdb-find-translate-path-includes-default'. > This routine does not depend on the cache, but will always derive > @@ -435,7 +438,9 @@ > nexttable) > (cond ((null path) > (semantic-refresh-tags-safe) > - (setq includetags (semantic-find-tags-included (current-buffer)) > + (setq includetags (append > + (semantic-find-tags-included (current-buffer)) > + semanticdb-implied-include-tags) > curtable semanticdb-current-table > incfname (buffer-file-name)) > ) > > ---------- > > You could then write something like: > > (defvar-mode-local c++-mode semanticdb-implied-include-tags > (list (semantic-tag-include "ipch.hxx"))) > > to make your case work. > > If this concept works, for your case, I'll see what sorts of things I > can do in EDE for this situation. > > Eric > > |
From: Eric M. L. <er...@si...> - 2009-07-12 13:53:33
|
Hi, That is quite the config file you have there. I don't see much wrong with your configuration. I know vector worked for me on my old machine, but my new machine with ubuntu also has the problem you described. It turns out that vector is in: std::_GLIBCXX_STD_D::vector, which I think is std::__norm::vector. This is might be related to the email David sent recently. all the latest headers seem to use _GLIBCXX_BEGIN_NESTED_NAMESPACE to declare the namespaces, which is a macro that needed special attention in Semantic's pre-processor. It expands as: # define _GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y) namespace X { namespace Y _GLIBCXX_VISIBILITY_ATTR(default) { which is using some visibility attribute. If someone could recommend what I should do with this double-nested namespace macro, such as never including the Y part, I'd appreciate it. I've checked in a change to semantic-c to create a configuration variable semantic-lex-c-nested-namespace-ignore-second which I defaulted to 't', or the value you want. I tried it out, and this solved your example for me. Eric On Fri, 2009-07-10 at 10:09 +0400, Denis Sukhonin wrote: > It's works after evaluating > (setf semanticdb-implied-include-tags > (semantic-find-tags-included > (ede-expand-filename (ede-toplevel) "pch.hxx"))) > in buffer with cxx-file. > Thanks. > > But now I can't get autocomplete for this simple case: > std::vector<int> v; > v.[M-x semantic-ia-complete-symbol-menu] > > I get this: > semantic-analyze-possible-completions-default: Cannot find types for > `std::vector v' > Aurgh! The same when I write just vector without namespace. > I have recreated semanticdb-default-save-directory and nothing changes. > Note, std::vect[M-x semantic-ia-complete-symbol-menu] works and finds > std::vector{}. > > I use latest emacs and cedet from CVS. > My configuration: > (load-file "~/.emacs.d/elisp/cedet/common/cedet.el") > (setq semantic-load-turn-useful-things-on t) > (semantic-load-enable-excessive-code-helpers) > ;;(semantic-load-enable-semantic-debugging-helpers) > > (setq > senator-minor-mode-name "SN" > semantic-imenu-auto-rebuild-directory-indexes nil) > > (global-srecode-minor-mode 1) > (global-semantic-mru-bookmark-mode 1) > (global-semantic-folding-mode 1) ; hide and show blocks > (global-semantic-idle-tag-highlight-mode 1) > > (require 'semantic-decorate-include) > (require 'semantic-ia) > (require 'semantic-tag) > > (setq-mode-local c-mode semanticdb-find-default-throttle > '(project unloaded system recursive)) > (setq-mode-local c++-mode semanticdb-find-default-throttle > '(project unloaded system recursive)) > (setq-mode-local erlang-mode semanticdb-find-default-throttle > '(project unloaded system recursive)) > > ;; Enable SemanticDB. > (require 'semanticdb) > (require 'semantic-gcc) > (semantic-gcc-setup) > (global-semanticdb-minor-mode 1) > (setq semanticdb-default-save-directory "~/.tmp/semanticdb") > (when (not (file-exists-p semanticdb-default-save-directory)) > (make-directory semanticdb-default-save-directory)) > (setq boost-dir "/usr/include/boost") > (when (file-exists-p boost-dir) > (add-to-list 'semantic-lex-c-preprocessor-symbol-file > (concat boost-dir "/boost/config.hpp"))) > > ;; EAssist. > (when (require-maybe 'eassist) > (setq eassist-header-switches > (append eassist-header-switches > '(("hxx" "cxx") ("cxx" "hxx") > ("H" "cc") ("cc" "H")) > ))) > > ;; SpeedBar. > (require 'semantic-sb) > > ;; EDE. > (require 'semantic-lex-spp) > (global-ede-mode 1) > > ;; Enable Imenu. > (add-hook 'semantic-init-hooks > (lambda () > (imenu-add-to-menubar "TAGS"))) > > (defun negval:cedet-hook nil > (local-set-key (kbd "C-<return>") 'semantic-ia-complete-symbol) > (local-set-key (kbd "C-c ?") 'semantic-ia-complete-symbol-menu) > (local-set-key (kbd "C-c >") 'semantic-complete-analyze-inline) > (local-set-key (kbd "C-c =") 'semantic-decoration-include-visit) > (local-set-key (kbd "C-c p") 'semantic-analyze-proto-impl-toggle) > (local-set-key (kbd "C-c j") 'semantic-ia-fast-jump) > (local-set-key (kbd "C-c q") 'semantic-ia-show-doc) > (local-set-key (kbd "C-c s") 'semantic-ia-show-summary) > (local-set-key (kbd "C-c h") 'eassist-switch-h-cpp)) > > (add-hook 'c-mode-common-hook 'negval:cedet-hook) > (add-hook 'emacs-lisp-mode-hook 'negval:cedet-hook) > (add-hook 'erlang-mode-hook 'negval:cedet-hook) > > (custom-set-variables > '(semantic-idle-scheduler-work-idle-time 10) > '(semantic-self-insert-show-completion-function > (lambda nil (semantic-ia-complete-symbol-menu (point)))) > '(global-semantic-tag-folding-mode > t nil (semantic-util-modes))) > > Eric M. Ludlam wrote: > > On Wed, 2009-07-08 at 17:14 +0400, Denis Sukhonin wrote: > > > >> Hi, All! > >> > >> I have pch.hxx where i put all useful #include-s, for example <vector>. > >> It includes by adding -ipch.hxx option for gcc, not by #include. > >> > >> When i try autocomplete std::vect in somewhere in a cxx file i get this: > >> Cannot find types for `"std"' > >> But it works when i explicitly include <vector> in the cxx file. > >> > >> Is there any way to say to EDE to use that header? > >> > >> I attach a tarball with an example, look a file src/main.cxx. > >> > > > > Hi, > > I am not familiar with this gcc option, and as such have never thought > > to try to add such a feature. > > > > Here is a patch which I have not tested: > > > > Index: semanticdb-find.el > > =================================================================== > > RCS file: /cvsroot/cedet/cedet/semantic/semanticdb-find.el,v > > retrieving revision 1.77 > > diff -b -u -r1.77 semanticdb-find.el > > --- semanticdb-find.el 16 May 2009 11:45:58 -0000 1.77 > > +++ semanticdb-find.el 9 Jul 2009 01:31:52 -0000 > > @@ -421,6 +421,9 @@ > > and TAG is a clone of the include tag that was found.") > > (make-variable-buffer-local 'semanticdb-find-scanned-include-tags) > > > > +(defvar semanticdb-implied-include-tags nil > > + "Include tags implied for all files of a given mode.") > > + > > (defun semanticdb-find-translate-path-includes--internal (path) > > "Internal implementation of > > `semanticdb-find-translate-path-includes-default'. > > This routine does not depend on the cache, but will always derive > > @@ -435,7 +438,9 @@ > > nexttable) > > (cond ((null path) > > (semantic-refresh-tags-safe) > > - (setq includetags (semantic-find-tags-included (current-buffer)) > > + (setq includetags (append > > + (semantic-find-tags-included (current-buffer)) > > + semanticdb-implied-include-tags) > > curtable semanticdb-current-table > > incfname (buffer-file-name)) > > ) > > > > ---------- > > > > You could then write something like: > > > > (defvar-mode-local c++-mode semanticdb-implied-include-tags > > (list (semantic-tag-include "ipch.hxx"))) > > > > to make your case work. > > > > If this concept works, for your case, I'll see what sorts of things I > > can do in EDE for this situation. > > > > Eric > > > > > > |