If you are using CEDET with C or C++, then there are a few C/C++ specific options you may need to update.
C and C++ use pre-processor directives, and the semantic parser has some basic support for a pre-processor. As such, you may need to set up some macros. You can do that in two ways.
The first option is to create your own symbol map in Emacs Lisp. You can customize the preprocessor symbol map.
Table of c Preprocessor keywords used by the Semantic c lexer. Each entry is a cons cell like this: ( “keyword“ . ”REPLACEMENT” ) Where keyword is the macro that gets replaced in the lexical phase, and replacement is a string that is inserted in its place. Empty string implies that the lexical analyzer will discard keyword when it is encountered.
Alternately, it can be of the form: ( “keyword“ ( lexsym1 “str” 1 1 ) ... ( lexsymn ”str” 1 1 ) ) where lexsym is a symbol that would normally be produced by the lexical analyzer, such as
symbolor string. The string in the second position is the text that makes up the replacement. This is the way to have multiple lexical symbols in a replacement. Using the first way to specify text like “foo::bar” would not work, because : is a separate lexical symbol.
A quick way to see what you would need to insert is to place a definition such as:
#define mysym foo::bar
into a c file, and do this: M-x semantic-lex-spp-describe
The output table will describe the symbols needed.
Alternately, you can use an existing C header file, or write your own custom C header file, and use the macros in that to initialize the preprocessor list.
List of c/c++ files that contain preprocessor macros for the c lexer. Each entry is a filename and each file is parsed, and those macros are included in every c/c++ file parsed by semantic. You can use this variable instead of
semantic-lex-c-preprocessor-symbol-mapto store your global macros in a more natural way.
Some such symbols for stdio.h as found on Linux are defined in
Lastly, you could just opt to ignore conditional parsing.
If you are having problems with smart completion and STL templates, it may that this is set incorrectly. After changing the value of this flag, you will need to delete any semanticdb cache files that may have been incorrectly parsed.
If you want the code-completion to work with C++ system header file,
you will need to update
M-x customize-variable RET semantic-c-dependency-system-include-path RET
Customizing this variable will allow you to setup your system include path and will update all files when you use custom to do it.
For large C or C++ programs, it is important to setup EDE for it. While EDE can be used to create Makefiles or use Automake files, EDE also provides a way to merely describe a project so that tools like semantic can find your sources.
If your project already uses Automake, or if your project is Emacs or the Linux Kernel, there are pre-existing EDE project types that will automatically detect these projects.
If you use a generic project type, such as Make (using a Makefile),
SCons, or CMake, you can use a see Generic.
Generic projects allow some basic customization for C/C++. Enable
generic projects with
If the options there are insufficient, or if Generic projects can't
identify your build system you will need to use the very simple
ede-cpp-root-project type. To use it, add this to your
.emacs file, or other configuration:
(global-ede-mode 1) ;; Enable EDE (ede-cpp-root-project "SOMENAME" :file "/dir/to/some/file")
where SOMENAME is a name for this project, and the file is a file name that exists at the root of your project directory. There are many more options for the optimization of finding your header files. For more on this option, including include path setting, and providing macro to the C pre-processor, see see ede-cpp-root.