unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* C preprocessor defines not taken into account by Cedet/Semantic
@ 2011-09-04 14:46 Abdellatif El Khlifi
  2011-09-05 16:57 ` Steve Revilak
  0 siblings, 1 reply; 4+ messages in thread
From: Abdellatif El Khlifi @ 2011-09-04 14:46 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 12270 bytes --]

Hello,

I am trying to use Emacs as an IDE in my Linux kernel development projects.
So I installed CEDET and GNU Global (gtags) with no problems.

When I open a C source code belonging to my Linux kernel source folder, the
linux project is detected automatically. Functions, variables, headers and
other keywords are highlighted correctly.

Through the ~/.emacs file I configured semantic's code completion and
intellisense. So when I press C-<SPC> the code completion menu appears and I
can choose what's needed.

The issue is when I use preprocessor defines, the intellisense system shows
the menu on the current location but doesn't detect the right things when
invoked (C-<SPC>). Even I close and restart emacs the same behavior is
reproduced.

The test code is:

//----------------------------------------------------------------------------------------

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;

//----------------------------------------------------------------------------------------

__KERNEL__ , USE1 and __LINUX_ARM_ARCH__ are already defined as follows:

__KERNEL__ : (add-to-list 'semantic-lex-c-preprocessor-symbol-map
'("__KERNEL__" . "")) in .emacs
USE1 : defined in a header file included by the current C source file.
__LINUX_ARM_ARCH__ : (add-to-list 'semantic-lex-c-preprocessor-symbol-file
"/home/abdellatif/kernel/include/generated/autoconf.h") in .emacs

In the .emacs file I also added all the needed includes and defines required
by GCC cross compiler (GCC for ARM) to build the kernel project.

I also tried to force semantic to use GCC cross compiler command line in
place of the system GCC to preprocess correctly but haven't found how to do
that.


The .emacs file, the output of the "M-x semantic-c-describe-environment"
command and the software versions are shown below.

Any help or indication is welcomed :)
Best regards

############# 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)

############# semantic-c-describe-environment #############

Calculated GCC Parameters:
  version = 4.5.2
  --target = i686-linux-gnu
  --host = i686-linux-gnu
  --build = i686-linux-gnu
  --enable-checking = release
  --with-tune = generic
  --with-arch-32 = i686
  --disable-werror = nil
  --enable-targets = all
  --enable-objc-gc = nil
  --with-plugin-ld = ld.gold
  --enable-ld = default
  --enable-gold = nil
  --enable-plugin = nil
  --enable-libstdcxx-time = yes
  --enable-libstdcxx-debug = nil
  --enable-clocale = gnu
  --with-sysroot = /
  --enable-nls = nil
  --libdir = /usr/lib/i386-linux-gnu
  --with-gxx-include-dir = /usr/include/c++/4.5
  --enable-threads = posix
  --without-included-gettext = nil
  --libexecdir = /usr/lib/i386-linux-gnu
  --with-system-zlib = nil
  --enable-linker-build-id = nil
  --with-multiarch-defaults = i386-linux-gnu
  --enable-multiarch = nil
  --enable-shared = nil
  --program-suffix = -4.5
  --prefix = /usr
  --enable-languages = c,c++,fortran,objc,obj-c++
  --with-bugurl = file:///usr/share/doc/gcc-4.5/README.Bugs
  4.5.2-8ubuntu4' = nil
  --with-pkgversion = 'Ubuntu/Linaro
  -v = nil
  target = i686-linux-gnu

Include Path Summary:

  This file's system include path is:

/home/abdellatif/toolchain/arm-eabi-4.4.3/lib/gcc/arm-eabi/4.4.3/include/
    /home/abdellatif/kernel/arch/arm/include/
    /home/abdellatif/kernel/include/
    /home/abdellatif/kernel/arch/arm/mach-omap2/include/
    /home/abdellatif/kernel/arch/arm/plat-omap/include/


Macro Summary:

  Your CPP table is primed from these files:
    /home/abdellatif/kernel/include/generated/autoconf.h
    in table: #<semanticdb-table autoconf.h (652 tags)>
    /usr/include/c++/4.5/i686-linux-gnu/bits/c++config.h
    in table: #<semanticdb-table c++config.h (193 tags)>

  Built-in symbol map:
    __THROW =
    __const = const
    __restrict =
    __declspec = ((spp-arg-list (foo) 1 . 2))
    __attribute__ = ((spp-arg-list (foo) 1 . 2))

  User symbol map:
    KBUILD_MODNAME = KBUILD_STR(main)
    KBUILD_BASENAME = KBUILD_STR(main)
    KBUILD_STR(s) = #s
    __LINUX_ARM_ARCH__ = 7
    __KERNEL__ =
    __DBL_MIN_EXP__ = (-1021)
    __pentiumpro__ = 1
    __UINT_LEAST16_MAX__ = 65535
    __FLT_MIN__ = 1.17549435082228750797e-38F
    __CHAR_BIT__ = 8
    __UINT8_MAX__ = 255
    __WINT_MAX__ = 4294967295U
    __SIZE_MAX__ = 4294967295U
    __WCHAR_MAX__ = 2147483647
    __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 = 1
    __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 = 1
    __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 = 1
    __DBL_DENORM_MIN__ = ((double)4.94065645841246544177e-324L)
    __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 = 1
    __FLT_EVAL_METHOD__ = 2
    __unix__ = 1
    __UINT_FAST64_MAX__ = 18446744073709551615ULL
    __SIG_ATOMIC_TYPE__ = int
    __DBL_MIN_10_EXP__ = (-307)
    __FINITE_MATH_ONLY__ = 0
    __GNUC_PATCHLEVEL__ = 2
    __UINT_FAST8_MAX__ = 255
    __DEC64_MAX_EXP__ = 385
    __INT8_C(c) = c
    __UINT_LEAST64_MAX__ = 18446744073709551615ULL
    __SHRT_MAX__ = 32767
    __LDBL_MAX__ = 1.18973149535723176502e+4932L
    __UINT_LEAST8_MAX__ = 255
    __linux = 1
    __DEC32_EPSILON__ = 1E-6DF
    __unix = 1
    __UINT32_MAX__ = 4294967295U
    __LDBL_MAX_EXP__ = 16384
    __WINT_MIN__ = 0U
    __linux__ = 1
    __SCHAR_MAX__ = 127
    __DBL_DIG__ = 15
    _FORTIFY_SOURCE = 2
    __SIZEOF_INT__ = 4
    __SIZEOF_POINTER__ = 4
    __STDC_HOSTED__ = 1
    __LDBL_HAS_INFINITY__ = 1
    __FLT_EPSILON__ = 1.19209289550781250000e-7F
    __GXX_WEAK__ = 1
    __LDBL_MIN__ = 3.36210314311209350626e-4932L
    __DEC32_MAX__ = 9.999999E96DF
    __INT32_MAX__ = 2147483647
    __SIZEOF_LONG__ = 4
    __UINT16_C(c) = c
    __DECIMAL_DIG__ = 21
    __gnu_linux__ = 1
    __LDBL_HAS_QUIET_NAN__ = 1
    __GNUC__ = 4
    __GXX_RTTI = 1
    __FLT_HAS_DENORM__ = 1
    __SIZEOF_LONG_DOUBLE__ = 12
    __BIGGEST_ALIGNMENT__ = 16
    __i686 = 1
    __DBL_MAX__ = ((double)1.79769313486231570815e+308L)
    __INT_FAST32_MAX__ = 2147483647
    __DBL_HAS_INFINITY__ = 1
    __INT64_MAX__ = 9223372036854775807LL
    __DEC32_MIN_EXP__ = (-94)
    __INT_FAST16_TYPE__ = int
    __LDBL_HAS_DENORM__ = 1
    __cplusplus = 1
    __DEC128_MAX__ = 9.999999999999999999999999999999999E6144DL
    __INT_LEAST32_MAX__ = 2147483647
    __DEC32_MIN__ = 1E-95DF
    __DEPRECATED = 1
    __DBL_MAX_EXP__ = 1024
    __DEC128_EPSILON__ = 1E-33DL
    __PTRDIFF_MAX__ = 2147483647
    __GNUG__ = 4
    __LONG_LONG_MAX__ = 9223372036854775807LL
    __SIZEOF_SIZE_T__ = 4
    __SIZEOF_WINT_T__ = 4
    __GCC_HAVE_DWARF2_CFI_ASM = 1
    __GXX_ABI_VERSION = 1002
    __FLT_MIN_EXP__ = (-125)
    __i686__ = 1
    __DBL_MIN__ = ((double)2.22507385850720138309e-308L)
    __FLT_MIN_10_EXP__ = (-37)
    __DECIMAL_BID_FORMAT__ = 1
    __DEC128_MIN__ = 1E-6143DL
    __UINT16_MAX__ = 65535
    __DBL_HAS_DENORM__ = 1
    __NO_INLINE__ = 1
    __i386 = 1
    __FLT_MANT_DIG__ = 24
    __VERSION__ = "4.5.2"
    __INT32_C(c) = c
    __DEC64_EPSILON__ = 1E-15DD
    __DEC128_MIN_EXP__ = (-6142)
    __INT_FAST32_TYPE__ = int
    unix = 1
    __INT16_MAX__ = 32767
    __i386__ = 1
    __UINT64_MAX__ = 18446744073709551615ULL
    __ELF__ = 1
    __FLT_RADIX__ = 2
    __LDBL_EPSILON__ = 1.08420217248550443401e-19L
    __SIG_ATOMIC_MAX__ = 2147483647
    __SIZEOF_PTRDIFF_T__ = 4
    __DEC32_SUBNORMAL_MIN__ = 0.000001E-95DF
    __pentiumpro = 1
    __INT_FAST16_MAX__ = 2147483647
    __UINT_FAST32_MAX__ = 4294967295U
    __FLT_HAS_QUIET_NAN__ = 1
    __FLT_MAX_10_EXP__ = 38
    __LONG_MAX__ = 2147483647L
    __DEC128_SUBNORMAL_MIN__ = 0.000000000000000000000000000000001E-6143DL
    __FLT_HAS_INFINITY__ = 1
    __DEC64_MAX__ = 9.999999999999999E384DD
    __PRAGMA_REDEFINE_EXTNAME = 1
    __INT_LEAST16_MAX__ = 32767
    __DEC64_MANT_DIG__ = 16
    __UINT_LEAST32_MAX__ = 4294967295U
    __DEC32_MAX_EXP__ = 97
    __INT_FAST8_MAX__ = 127
    __INTPTR_MAX__ = 2147483647
    linux = 1
    __EXCEPTIONS = 1
    __LDBL_MANT_DIG__ = 64
    __DBL_HAS_QUIET_NAN__ = 1
    __INTPTR_TYPE__ = int
    __WCHAR_TYPE__ = int
    __SIZEOF_FLOAT__ = 4
    __UINTPTR_MAX__ = 4294967295U
    __DEC64_MIN_EXP__ = (-382)
    __INT_FAST64_MAX__ = 9223372036854775807LL
    __FLT_DIG__ = 6
    __INT_MAX__ = 2147483647
    __FLT_MAX_EXP__ = 128
    __DBL_MANT_DIG__ = 53
    __INT_LEAST64_MAX__ = 9223372036854775807LL
    __DEC64_MIN__ = 1E-383DD
    __SIZEOF_SHORT__ = 2
    __LDBL_MIN_EXP__ = (-16381)
    __INT_LEAST8_MAX__ = 127
    __SSP__ = 1
    __LDBL_MAX_10_EXP__ = 4932
    __DBL_EPSILON__ = ((double)2.22044604925031308085e-16L)
    __UINT8_C(c) = c
    __INT_LEAST32_TYPE__ = int
    __SIZEOF_WCHAR_T__ = 4
    __DEC_EVAL_METHOD__ = 2
    __INTMAX_MAX__ = 9223372036854775807LL
    __FLT_DENORM_MIN__ = 1.40129846432481707092e-45F
    __INT8_MAX__ = 127
    __FLT_MAX__ = 3.40282346638528859812e+38F
    __INT32_TYPE__ = int
    __SIZEOF_DOUBLE__ = 8
    i386 = 1
    __DEC128_MAX_EXP__ = 6145
    __GNUC_MINOR__ = 5
    __UINTMAX_MAX__ = 18446744073709551615ULL
    __DEC32_MANT_DIG__ = 7
    __DBL_MAX_10_EXP__ = 308
    __LDBL_DENORM_MIN__ = 3.64519953188247460253e-4951L
    __INT16_C(c) = c
    __STDC__ = 1
    __PTRDIFF_TYPE__ = int
    __DEC64_SUBNORMAL_MIN__ = 0.000000000000001E-383DD
    __DEC128_MANT_DIG__ = 34
    __LDBL_MIN_10_EXP__ = (-4931)
    __SIZEOF_LONG_LONG__ = 8
    __LDBL_DIG__ = 18
    __UINT_FAST16_MAX__ = 4294967295U
    __GNUC_GNU_INLINE__ = 1
    _GNU_SOURCE = 1


-- 
Abdellatif El Khlifi
abdellatif@ieee.org
http://abdellatif.emurse.com/

[-- Attachment #2: Type: text/html, Size: 17794 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: C preprocessor defines not taken into account by Cedet/Semantic
  2011-09-04 14:46 C preprocessor defines not taken into account by Cedet/Semantic Abdellatif El Khlifi
@ 2011-09-05 16:57 ` Steve Revilak
  2011-09-05 17:02   ` Richard Riley
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Revilak @ 2011-09-05 16:57 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1032 bytes --]

>From: Abdellatif El Khlifi

>I am trying to use Emacs as an IDE in my Linux kernel development projects.
>So I installed CEDET and GNU Global (gtags) with no problems.
>
>When I open a C source code belonging to my Linux kernel source folder, the
>linux project is detected automatically. Functions, variables, headers and
>other keywords are highlighted correctly.
>
>Through the ~/.emacs file I configured semantic's code completion and
>intellisense. So when I press C-<SPC> the code completion menu appears and I
>can choose what's needed.
>
>The issue is when I use preprocessor defines, the intellisense system shows
>the menu on the current location but doesn't detect the right things when
>invoked (C-<SPC>). Even I close and restart emacs the same behavior is
>reproduced.


I thought that global didn't index preprocessor defines.

If you cd to the directory containing GTAGS and run

   global FOO

where FOO is the name of a #define'd preprocessor symbol, does global
output the file containing the definition?

Steve

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: C preprocessor defines not taken into account by Cedet/Semantic
  2011-09-05 16:57 ` Steve Revilak
@ 2011-09-05 17:02   ` Richard Riley
  2011-09-05 20:30     ` Abdellatif El Khlifi
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Riley @ 2011-09-05 17:02 UTC (permalink / raw)
  To: help-gnu-emacs

Steve Revilak <steve@srevilak.net> writes:

>>From: Abdellatif El Khlifi
>
>>I am trying to use Emacs as an IDE in my Linux kernel development projects.
>>So I installed CEDET and GNU Global (gtags) with no problems.
>>
>>When I open a C source code belonging to my Linux kernel source folder, the
>>linux project is detected automatically. Functions, variables, headers and
>>other keywords are highlighted correctly.
>>
>>Through the ~/.emacs file I configured semantic's code completion and
>>intellisense. So when I press C-<SPC> the code completion menu appears and I
>>can choose what's needed.
>>
>>The issue is when I use preprocessor defines, the intellisense system shows
>>the menu on the current location but doesn't detect the right things when
>>invoked (C-<SPC>). Even I close and restart emacs the same behavior is
>>reproduced.
>
> I thought that global didn't index preprocessor defines.
>

No, but Cedet should/could/does. It parses the C++ itself.






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: C preprocessor defines not taken into account by Cedet/Semantic
  2011-09-05 17:02   ` Richard Riley
@ 2011-09-05 20:30     ` Abdellatif El Khlifi
  0 siblings, 0 replies; 4+ messages in thread
From: Abdellatif El Khlifi @ 2011-09-05 20:30 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1375 bytes --]

Is there a way to tell to CEDET, don't use your preprocessor. I've the mine.
And then I give the gcc command line I want (already tested on my project
and do preprocessing correctly) ?

On Mon, Sep 5, 2011 at 6:02 PM, Richard Riley <rileyrg@googlemail.com>wrote:

> Steve Revilak <steve@srevilak.net> writes:
>
> >>From: Abdellatif El Khlifi
> >
> >>I am trying to use Emacs as an IDE in my Linux kernel development
> projects.
> >>So I installed CEDET and GNU Global (gtags) with no problems.
> >>
> >>When I open a C source code belonging to my Linux kernel source folder,
> the
> >>linux project is detected automatically. Functions, variables, headers
> and
> >>other keywords are highlighted correctly.
> >>
> >>Through the ~/.emacs file I configured semantic's code completion and
> >>intellisense. So when I press C-<SPC> the code completion menu appears
> and I
> >>can choose what's needed.
> >>
> >>The issue is when I use preprocessor defines, the intellisense system
> shows
> >>the menu on the current location but doesn't detect the right things when
> >>invoked (C-<SPC>). Even I close and restart emacs the same behavior is
> >>reproduced.
> >
> > I thought that global didn't index preprocessor defines.
> >
>
> No, but Cedet should/could/does. It parses the C++ itself.
>
>
>
>
>


-- 
Abdellatif El Khlifi
abdellatif@ieee.org
http://abdellatif.emurse.com/

[-- Attachment #2: Type: text/html, Size: 2093 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-09-05 20:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-04 14:46 C preprocessor defines not taken into account by Cedet/Semantic Abdellatif El Khlifi
2011-09-05 16:57 ` Steve Revilak
2011-09-05 17:02   ` Richard Riley
2011-09-05 20:30     ` Abdellatif El Khlifi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).