all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Semantic mode for c++
@ 2017-06-26 12:34 Gabriele Labita
  2017-06-26 13:42 ` Bastian Beischer
  0 siblings, 1 reply; 3+ messages in thread
From: Gabriele Labita @ 2017-06-26 12:34 UTC (permalink / raw
  To: help-gnu-emacs

Hi,
I'm trying to configure semantic module to have auto completion for c++ 
in emacs.
I put this code on .emacs file:

```
  (add-hook 'c-mode-common-hook
        '(lambda () (load (concat custom-config-path 
"custom-config-c++.el")))
)
  ```

And this is my custom-config-c++.el file:
```
(add-to-list 'semantic-default-submodes 
'global-semantic-idle-scheduler-mode)
(add-to-list 'semantic-default-submodes 
'global-semantic-idle-completions-mode)
(add-to-list 'semantic-default-submodes 'global-semantic-idle-summary-mode)
(add-to-list 'semantic-default-submodes 'global-semanticdb-minor-mode)
(add-to-list 'semantic-default-submodes 
'global-semantic-show-parser-state-mode)
(add-to-list 'semantic-default-submodes 
'global-semantic-show-unmatched-syntax-mode)

(semantic-mode 1)

(require 'semantic/ia)
(require 'semantic/bovine/gcc)

(semanticdb-enable-gnu-global-databases 'c++-mode)

(global-ede-mode t)

(global-flycheck-mode t)
(setq flycheck-gcc-language-standard "c++14")
;; To add library use follow command:
;;   > flycheck-pkg-config

;; 70 Columns RULE
(require 'whitespace)
(setq whitespace-line-column 71)
(setq whitespace-style '(face lines-tail))

(global-whitespace-mode +1)
  ```

It works well but I've a annoying problem: when I use the command: 
'semantic-ia-complete-symbol' on 'std::', the semantic db is created in 
the .emacs.d/semanticdb/ folder. The problem is that the created db 
refers to c++98 instead of c++14. For example: when auto complete smart 
pointers, I find the "auto_ptr" suggestion and not "unique_ptr" or 
"shared_ptr".
How can I generate the right db?

More Infos:
- Debian 9 amd 64
- gcc 6.3.0
- Emacs 24.5.1
- global 6.5.6



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

* Re: Semantic mode for c++
  2017-06-26 12:34 Semantic mode for c++ Gabriele Labita
@ 2017-06-26 13:42 ` Bastian Beischer
  2017-06-26 21:32   ` Gabriele Labita
  0 siblings, 1 reply; 3+ messages in thread
From: Bastian Beischer @ 2017-06-26 13:42 UTC (permalink / raw
  To: Gabriele Labita; +Cc: Help-Gnu-Emacs

Hey,

I guess the problem is that the semantic lexer does not set the correct
preprocessor macros when lexing the STL include files. In particular, to
set the C++ standard version, one has to set the __cplusplus macro to a
particular value. The compiler does this automatically for you when you
compile with -std=XXX, but semantic does not know anything about this
compiler flag.

You can customize the macro definitions used in semantic in the variable
"semantic-lex-c-preprocessor-symbol-map".

However, I don't think semantic currently supports all the new C++11 and
above keywords which have entered the language when parsing code, so you
might get mixed results.

Cheers
Bastian

On Mon, Jun 26, 2017 at 2:34 PM, Gabriele Labita <gabriele.labita@gmail.com>
wrote:

> Hi,
> I'm trying to configure semantic module to have auto completion for c++ in
> emacs.
> I put this code on .emacs file:
>
> ```
>  (add-hook 'c-mode-common-hook
>        '(lambda () (load (concat custom-config-path
> "custom-config-c++.el")))
> )
>  ```
>
> And this is my custom-config-c++.el file:
> ```
> (add-to-list 'semantic-default-submodes 'global-semantic-idle-schedule
> r-mode)
> (add-to-list 'semantic-default-submodes 'global-semantic-idle-completi
> ons-mode)
> (add-to-list 'semantic-default-submodes 'global-semantic-idle-summary-
> mode)
> (add-to-list 'semantic-default-submodes 'global-semanticdb-minor-mode)
> (add-to-list 'semantic-default-submodes 'global-semantic-show-parser-s
> tate-mode)
> (add-to-list 'semantic-default-submodes 'global-semantic-show-unmatche
> d-syntax-mode)
>
> (semantic-mode 1)
>
> (require 'semantic/ia)
> (require 'semantic/bovine/gcc)
>
> (semanticdb-enable-gnu-global-databases 'c++-mode)
>
> (global-ede-mode t)
>
> (global-flycheck-mode t)
> (setq flycheck-gcc-language-standard "c++14")
> ;; To add library use follow command:
> ;;   > flycheck-pkg-config
>
> ;; 70 Columns RULE
> (require 'whitespace)
> (setq whitespace-line-column 71)
> (setq whitespace-style '(face lines-tail))
>
> (global-whitespace-mode +1)
>  ```
>
> It works well but I've a annoying problem: when I use the command:
> 'semantic-ia-complete-symbol' on 'std::', the semantic db is created in the
> .emacs.d/semanticdb/ folder. The problem is that the created db refers to
> c++98 instead of c++14. For example: when auto complete smart pointers, I
> find the "auto_ptr" suggestion and not "unique_ptr" or "shared_ptr".
> How can I generate the right db?
>
> More Infos:
> - Debian 9 amd 64
> - gcc 6.3.0
> - Emacs 24.5.1
> - global 6.5.6
>
>


-- 
Bastian Beischer
RWTH Aachen University of Technology

@RWTH Aachen
Office: 28 C 203
Phone: +49-241-80-27205
E-mail: beischer@physik.rwth-aachen.de
Address: I. Physikalisches Institut B, Sommerfeldstr. 14, D-52074 Aachen

@CERN
Office: Bdg 32-4-B12
Phone: +41-22-76-75750
E-mail: bastian.beischer@cern.ch
Address: CERN, CH-1211 Geneve 23


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

* Re: Semantic mode for c++
  2017-06-26 13:42 ` Bastian Beischer
@ 2017-06-26 21:32   ` Gabriele Labita
  0 siblings, 0 replies; 3+ messages in thread
From: Gabriele Labita @ 2017-06-26 21:32 UTC (permalink / raw
  To: help-gnu-emacs

Hi,
Thank you for the reply. I've checked the
"semantic-lex-c-preprocessor-symbol-map" and I found:
  ("__cplusplus" . "201402L")

I think it is right, because reading the code of stl I found this kind
of preprocessor directives:
   #if __cplusplus > 201103L

Maybe the problem to be the missing support for new C++11. As you say
I've got a mixed result.

Is there an other emacs package to do the same thing?
I found something on the net, but all of them use "clang" and I prefer
to not install it. I would like to use g++.

Gabriele L.

P.s. When I tried to reply through client mail I had some errors. I saw on
browser that it sent about 12 mail. I don't know what happen but I'm very
sorry for the inconvenience. Ignore all previous mail.


2017-06-26 15:42 GMT+02:00 Bastian Beischer <bastian.beischer@rwth-aachen.de
>:

> Hey,
>
> I guess the problem is that the semantic lexer does not set the correct
> preprocessor macros when lexing the STL include files. In particular, to
> set the C++ standard version, one has to set the __cplusplus macro to a
> particular value. The compiler does this automatically for you when you
> compile with -std=XXX, but semantic does not know anything about this
> compiler flag.
>
> You can customize the macro definitions used in semantic in the variable
> "semantic-lex-c-preprocessor-symbol-map".
>
> However, I don't think semantic currently supports all the new C++11 and
> above keywords which have entered the language when parsing code, so you
> might get mixed results.
>
> Cheers
> Bastian
>
> On Mon, Jun 26, 2017 at 2:34 PM, Gabriele Labita <
> gabriele.labita@gmail.com> wrote:
>
>> Hi,
>> I'm trying to configure semantic module to have auto completion for c++
>> in emacs.
>> I put this code on .emacs file:
>>
>> ```
>>  (add-hook 'c-mode-common-hook
>>        '(lambda () (load (concat custom-config-path
>> "custom-config-c++.el")))
>> )
>>  ```
>>
>> And this is my custom-config-c++.el file:
>> ```
>> (add-to-list 'semantic-default-submodes 'global-semantic-idle-schedule
>> r-mode)
>> (add-to-list 'semantic-default-submodes 'global-semantic-idle-completi
>> ons-mode)
>> (add-to-list 'semantic-default-submodes 'global-semantic-idle-summary-
>> mode)
>> (add-to-list 'semantic-default-submodes 'global-semanticdb-minor-mode)
>> (add-to-list 'semantic-default-submodes 'global-semantic-show-parser-s
>> tate-mode)
>> (add-to-list 'semantic-default-submodes 'global-semantic-show-unmatche
>> d-syntax-mode)
>>
>> (semantic-mode 1)
>>
>> (require 'semantic/ia)
>> (require 'semantic/bovine/gcc)
>>
>> (semanticdb-enable-gnu-global-databases 'c++-mode)
>>
>> (global-ede-mode t)
>>
>> (global-flycheck-mode t)
>> (setq flycheck-gcc-language-standard "c++14")
>> ;; To add library use follow command:
>> ;;   > flycheck-pkg-config
>>
>> ;; 70 Columns RULE
>> (require 'whitespace)
>> (setq whitespace-line-column 71)
>> (setq whitespace-style '(face lines-tail))
>>
>> (global-whitespace-mode +1)
>>  ```
>>
>> It works well but I've a annoying problem: when I use the command:
>> 'semantic-ia-complete-symbol' on 'std::', the semantic db is created in the
>> .emacs.d/semanticdb/ folder. The problem is that the created db refers to
>> c++98 instead of c++14. For example: when auto complete smart pointers, I
>> find the "auto_ptr" suggestion and not "unique_ptr" or "shared_ptr".
>> How can I generate the right db?
>>
>> More Infos:
>> - Debian 9 amd 64
>> - gcc 6.3.0
>> - Emacs 24.5.1
>> - global 6.5.6
>>
>>
>
>
> --
> Bastian Beischer
> RWTH Aachen University of Technology
>
> @RWTH Aachen
> Office: 28 C 203
> Phone: +49-241-80-27205 <+49%20241%208027205>
> E-mail: beischer@physik.rwth-aachen.de
> Address: I. Physikalisches Institut B, Sommerfeldstr. 14, D-52074 Aachen
>
> @CERN
> Office: Bdg 32-4-B12
> Phone: +41-22-76-75750
> E-mail: bastian.beischer@cern.ch
> Address: CERN, CH-1211 Geneve 23
>



-- 
Gabriele Labita


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

end of thread, other threads:[~2017-06-26 21:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-26 12:34 Semantic mode for c++ Gabriele Labita
2017-06-26 13:42 ` Bastian Beischer
2017-06-26 21:32   ` Gabriele Labita

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.