Re: [cedet-semantic] Is it a Bug?
Brought to you by:
zappo
From: David E. <de...@ra...> - 2009-08-05 14:55:45
|
Weiyu Yi <in...@go...> writes: > By my code, some classes are written by other ppl and possibly for the easy > migration or something else they define a macro like this > > #if defined(_WIN32) > #define MACRO __declspec(dllexport) > #blabla > > and use this MACRO for class definition > > class/struct MACRO classname > { > }; [...] > Could it be avoided by adding some configuration in .emacs? if not, I think > this could be put in TODO list and solved later. Yes, these types of attributes before class names seem to become a pretty common problem. I've encountered similar macros, e.g., with the Qt and Xapian library. You can solve this problem by giving Semantic a 'fake' definition of MACRO, the most simple being the empty string. You can do this with (add-to-list 'semantic-lex-c-preprocessor-symbol-map '("MACRO" . "")) Alternatively, and maybe easier to handle: you can also create a dummy header file, for example 'semanticdef.h', which only contains ---- semanticdef.h ----- #define MACRO ------------------------ Then, you add this file to semantic-lex-c-preprocessor-symbol-file: (add-to-list 'semantic-lex-c-preprocessor-symbol-file '"<FULL PATH>/foo.h") Whichever method you prefer, it is best to delete the cache files in ~/.semanticdb, otherwise Semantic might not parse the files with the new definition for MACRO. If it doesn't work, you can check if Semantic really knows MACRO by calling 'semantic-lex-spp-describe' while editing your C++ code. It will then show you every #define it has parsed. Be aware that simply #including the file 'semanticdef.h' in your code will *not* work, since Semantic does not by default includes every #define from all included header files (that would slow down parsing too much). It will only include those files listed in semantic-lex-c-preprocessor-symbol-file, and it will know those which you add manually to semantic-lex-c-preprocessor-symbol-map. Regards, David |