syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.64k stars 4.89k forks source link

Some bugs or questions about C-C++ layer #4493

Closed jcppython closed 4 years ago

jcppython commented 8 years ago

Here is my configuration screenshot from 2016-01-08 18 26 36

emacs-version GNU Emacs 24.4.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8)

  1. The "SPC m" is undefined when I open a C/C++ header file. In addition, the illustration of “Key Bindings” part has some wrongs in C-C++. https://github.com/fenxian/spacemacs/blob/master/layers/+lang/c-c++/README.org
  2. It can't find the C++ headers. screenshot from 2016-01-08 18 34 39 I need to configure it?
  3. An unfriendly tip as shown in following: screenshot from 2016-01-08 18 31 51

    And, the code is right. In other words, this tip shouldn't exist in here. In addition, how to open a header file? command or key binding?

  4. Can you give me more information about how to scan a big C/C++ project with spacemacs? For example, how to configure it for my project? How to jump to the definition of references?

Thank you~

tuhdo commented 8 years ago
  1. It's strange. If you enabled semantic layer, at least SPC m r should be available to access srefactor's menu.
  2. For C++ header files, you must add your C++ header paths to the variable company-c-headers-path-system for it to complete. Something like this:
(add-to-list 'company-c-headers-path-system "/usr/include/c++/4.8/" )

Because it's is system-specific, we cannot preconfigured it.

  1. As for the error message, probably it cannot find the header file. You might try adding project include paths for your C++ using the variable flycheck-clang-include-path.
  2. To jump around C++ source code, you can either use the gtags layer (after adding the layer, some SPC m key bindings for gtags should be available. Use the command helm-gtags-create-tags to generate a tag database at your project root. Then, you will be able to jump to definitions and find references.
jcppython commented 8 years ago
  1. screenshot from 2016-01-08 19 58 00

screenshot from 2016-01-08 20 00 52

Sorry, SPC m is undefined occuring some times. This situation is incidental... You can see that: I type SPC m g c to create gtags .. . You can try to SPC m when you open a C/C++ file immediately after you start spacemacs.

  1. Where is better place to add the following codes? dotspacemacs/user-config () ?

     (add-to-list 'company-c-headers-path-system "/usr/include/c++/4.8/" )

    May be we can add a variable to configure it when we enable C-C++ layer?

  2. What is different between flycheck-clang-include-path and company-c-headers-path-system / company-c-headers-usr-system? Do I should to add project include paths into company-c-headers-usr-system?
  3. I have jump operations when SPC m is available. I have another question: Could we can create tha gtags file into another folder? Because the project belong to a big team sometimes. I can't to write files into the root of project at that time.
TheBB commented 8 years ago

Are your packages updated? How old is your bind-map package?

jcppython commented 8 years ago

elpa/bind-map-20151217.829/..

I think it should be the latest. I install the spacemacs yesterday.

TheBB commented 8 years ago

Yeah ok, it's not that then. Can I try your dotfile?

jcppython commented 8 years ago

@TheBB dotfile refers to .spacemacs? It only have a little changes in this file. spacemacs.txt

TheBB commented 8 years ago

Okay, I tried with your dotfile (except I had to remove the chinese layer), and SPC m works fine for me in C++ mode.

jcppython commented 8 years ago

Yeah, It seems chinese layer leads to this issue. Then, I will have to remove chinese layer? ...

TheBB commented 8 years ago

Really? It works without the chinese layer?

jcppython commented 8 years ago

Sorry, I try to operate it more times. The problem still exist after I comment chinese layer. In addition, I find that SPC m can work after I have some other operations, for example, gg and G.

ps: SPC m works fine in other major-mode, for example, org-mode.

Can you give more methods to debug it? Or, Do you need some other information?

tshu-w commented 7 years ago

@jcppython I have the same issues with you. Have you fixed this problems?

tshu-w commented 7 years ago

@TheBB Hi, I have the same issues that can't find the C++ headers. Here is the problem that whether I set c-c++-default-mode-for-headers 'c++-mode or not company-c-headers find header files at /usr/include, but should be at /usr/include/c++/4.2.1.What should I set in my .spacemacs?

delaanthonio commented 7 years ago

@Voleking Do you have clang support enabled? If you do, create a .clang_complete file in the root of your project. Add the flag -I/usr/include/c++/4.2.1 to the beginning of the .clang_complete file. Otherwise, try adding (add-to-list 'company-c-headers-path-system "/usr/include/c++/4.2.1") to your .spacemacs.

syl20bnr commented 6 years ago

May be fixed in develop after https://github.com/syl20bnr/spacemacs/pull/9381 is merged.

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!