Semantic seems to be able to do this, but I cannot get it to work as I would expect it to. For example, if I #include "Type.h" and declare Type t, using semantic-complete-analyze-inline when point is after t. consistently gives me the error

Cannot find types for `Type t'

instead of giving me all of the public (or otherwise appropriate) members of t.

How can I get the result I'm looking for here? Ideally, how can I use whatever Semantic might provide as a backend for Company?

  • Are you sure Type.h exists, is being found, and declares the type Type? If I make Type.h and Type.cpp in the same directory with Type.h declaring a class Type with fields int foo and char bar, semantic and company work out of the box. – J David Smith Nov 10 '14 at 19:35
  • Have you verified if company-backends variable has company-semantic in its list? If not, you'll want to add prepend it to the first of the list so that it's searched first – cheezy Nov 10 '14 at 20:26
  • Interestingly, it works with the minimal example I describe. (Unfortunately I really can't give the actual use case, but it shouldn't matter.) Is there any way I can force Semantic to reparse everything? – Sean Allred Nov 10 '14 at 20:56
  • @JDavidSmith How can I ensure it is being found? The project I'm actually working with is very complex in its build structure. – Sean Allred Nov 10 '14 at 21:01
  • @cheezy company-semantic is in company-backends; thanks :) – Sean Allred Nov 10 '14 at 21:02

You probably want to follow the tutorial here and setup company-clang to get better candidates.


I suggest using irony-mode with company-irony for completion instead of semantic as semantic is generally too slow and simplistic - ie. it often doesn't offer completions when you would think it should.


First you need to initialize CEDET and ede

(global-ede-mode 1)
(add-to-list 'semantic-default-submodes 'global-semanticdb-minor-mode 1)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-scheduler-mode 1)
(add-to-list 'semantic-default-submodes 'global-semantic-stickyfunc-mode 1)
(add-to-list 'semantic-default-submodes 'global-semantic-highlight-func-mode 1)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-summary-mode t)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-completions-mode t)
(add-to-list 'semantic-default-submodes 'global-srecode-minor-mode t)
(add-to-list 'semantic-default-submodes 'global-semantic-decoration-mode t)
(semantic-mode) ;; Active le mode semantic
(require 'stickyfunc-enhance) ;; multilines concatene dans la header line
(require 'cedet-cscope)

(require 'ecb)
(ede-cpp-root-project "projName"
                  :name "projName Project"
                  :file "~/workspaces/projName/proj.txt" ;; an arbitrary file
                  :include-path '("/src/main/src"
                                  ... )
                  :system-include-path '("/usr/include/ ~/workspaces/install/proj3/lib/ /usr/include/boost/")
                  :spp-table '(("isUnix" . "") ("BOOST_TEST_DYN_LINK" . "")))
;; cedet semantic
(semanticdb-enable-gnu-global-databases 'c-mode t)
(semanticdb-enable-gnu-global-databases 'c++-mode t)
;; You can add this to improve the parse of macro-heavy code:
(require 'semantic/bovine/c)
(add-to-list 'semantic-lex-c-preprocessor-symbol-file "/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stddef.h")

then you can use company-c-headers (https://github.com/randomphrase/company-c-headers)

(require 'company-c-headers)
     (add-to-list 'company-backends 'company-c-headers)
     (add-to-list 'company-c-headers-path-system "/usr/include/c++/4.4.7/ /home/me/DEPEDENCIES/LIBXX/lib/ /home/me/DEPEDENCIES/LIBYY/lib /usr/include/boost/"))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.