Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jcppython opened this issue Jan 8, 2016 · 15 comments
Closed

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

jcppython opened this issue Jan 8, 2016 · 15 comments
Labels
C/C++ Fixed in develop Question stale marked as a stale issue/pr (usually by a bot)

Comments

@jcppython
Copy link

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~

@jcppython jcppython changed the title "SPC m" is undefined with opening C/C++ header files Some bugs or questions about C-C++ layer Jan 8, 2016
@tuhdo
Copy link
Contributor

tuhdo commented Jan 8, 2016

  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
Copy link
Author

  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?
  1. 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?
  2. 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
Copy link
Contributor

TheBB commented Jan 8, 2016

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

@jcppython
Copy link
Author

elpa/bind-map-20151217.829/..

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

@TheBB
Copy link
Contributor

TheBB commented Jan 8, 2016

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

@jcppython
Copy link
Author

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

@TheBB
Copy link
Contributor

TheBB commented Jan 8, 2016

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
Copy link
Author

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

@TheBB
Copy link
Contributor

TheBB commented Jan 8, 2016

Really? It works without the chinese layer?

@jcppython
Copy link
Author

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
Copy link
Contributor

tshu-w commented Apr 5, 2017

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

@tshu-w
Copy link
Contributor

tshu-w commented Apr 5, 2017

@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
Copy link
Contributor

@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.

fredrikbergstrand added a commit to fredrikbergstrand/spacemacs that referenced this issue Aug 12, 2017
This change makes the c-c++ layer configure company-c-headers to search for and
list completion alternatives according to the priority list found in 'man gcc'.
If supported, the default system include paths are also fetched from gcc's
configuration instead of being hard coded to "/usr/include" and
"/usr/local/include". This also remedies the problem where the C++ standard
library headers does not show up as completion alternatives without manual
addition of include paths (see syl20bnr#4493, syl20bnr#8655).
syl20bnr pushed a commit that referenced this issue Dec 19, 2017
This change makes the c-c++ layer configure company-c-headers to search for and
list completion alternatives according to the priority list found in 'man gcc'.
If supported, the default system include paths are also fetched from gcc's
configuration instead of being hard coded to "/usr/include" and
"/usr/local/include". This also remedies the problem where the C++ standard
library headers does not show up as completion alternatives without manual
addition of include paths (see #4493, #8655).
@syl20bnr
Copy link
Owner

May be fixed in develop after #9381 is merged.

buckarooch pushed a commit to profilech/.emacs.d that referenced this issue May 19, 2018
This change makes the c-c++ layer configure company-c-headers to search for and
list completion alternatives according to the priority list found in 'man gcc'.
If supported, the default system include paths are also fetched from gcc's
configuration instead of being hard coded to "/usr/include" and
"/usr/local/include". This also remedies the problem where the C++ standard
library headers does not show up as completion alternatives without manual
addition of include paths (see syl20bnr#4493, syl20bnr#8655).
CodingSolo pushed a commit to CodingSolo/spacemacs that referenced this issue Oct 29, 2018
This change makes the c-c++ layer configure company-c-headers to search for and
list completion alternatives according to the priority list found in 'man gcc'.
If supported, the default system include paths are also fetched from gcc's
configuration instead of being hard coded to "/usr/include" and
"/usr/local/include". This also remedies the problem where the C++ standard
library headers does not show up as completion alternatives without manual
addition of include paths (see syl20bnr#4493, syl20bnr#8655).
@github-actions
Copy link

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!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C/C++ Fixed in develop Question stale marked as a stale issue/pr (usually by a bot)
Projects
None yet
Development

No branches or pull requests

7 participants