Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c++]

Questions related to the C++ language or the cc-mode

2
votes
1answer
2k views

Add include paths to flycheck and to company-irony?

I am starting to develop a ROS (Robot Operating System) application for the first time using Emacs. Here is my ~/.emacs.d/init.el configuration for Flycheck and company packages: ;;;;;;;;;;;;;;;;;;;;;...
0
votes
1answer
130 views

Inconsistent Indentation for C/C++ Upon Loading File

Problem: When a C++ file is loaded, the indentation rules are not always what they should be, i.e. instead of indenting by 3, it will indent by 1 or 8 for that session. This occurs consistently ...
0
votes
3answers
3k views

spacemacs how to show the documentation of a function during autocomplete in c-c++ layer

I am looking for a good alternative ide for c++ and for that started to lern first vanilla emacs and now spacemacs. I have configured my .spacemacs now to be able to edit lisp code quite comfortably ...
0
votes
1answer
478 views

tab and spaces shown aligned in emacs C++ mode, but not in other editors

In Emacs' C++ mode, I sometimes accidentally introduced a tab where I should use four whitespaces instead to create indentations. Adjacent lines with mixed uses of tabs and spaces for indentations are ...
0
votes
0answers
137 views

font-lock problem of c++ mode

I recently notice that there's some strange behaviours of the font-lock of the c++-mode. Let's start emacs by emacs -Q in the terminal, edit a new file test.cpp and save the following contents Then ...
1
vote
1answer
915 views

company-mode clang error

I am following this tutorial When having enabled company-node upon typing for instance std::vec I get error message in the mini buffer saying: clang failed with error 1: /usr/bin/clang -fsyntax-only ...
2
votes
2answers
791 views

cc-styles c-offsets-alist setting for C++11 lambda brace indentation

I am trying to configure my cc-styles to use a single basic offset for the braces of an inline defined lambda. I have a function template which takes a functor as an argument template<typename ...
0
votes
0answers
192 views

Missing line breaks in flycheck/cppcheck

I'm using the spacemacs syntax-checking layer on my C++ code (under the covers, this uses flycheck and cppcheck). Some messages coming back from cppcheck extend across multiple lines. Specifically, I'...
1
vote
2answers
653 views

Binding compile command to a key for c++ code

Is it possible to bind the compile and run commands for a c++ code to a single key (for example F5). What i do at the moment is to run M-x compile and then as compile command g++ project.cpp and then ...
0
votes
1answer
723 views

irony mode not working in ubuntu 16.04

I'm updating my Ubuntu distro to LTS 16.04 release. I followed the instructions given at irony mode in github and company irony in github in order to get autocompletion features in Emacs. For both ...
2
votes
1answer
642 views

Configuring Emacs as a CMake based C/C++ IDE

I have been interested in Emacs for a while, since I have seen some great articles on the Internet, which demonstrates the usage of Emacs as a C/C++ IDE. Those projects are awesome, yet they are not ...
1
vote
0answers
40 views

C++ source highlight in Diff mode

I'd like to know if Emacs has an option to highlight the portions of C++ source inside .diff files generated by e.g. git diff HEAD~1 or git log -p Right now I have to rename my .diff file to ...
2
votes
1answer
602 views

Override c++-mode font lock

I am improving the C++ highlighting in Emacs with the minor mode: modern-cpp-font-lock. Consider this following C++14 code: int main() { int i = 1'2'3l; } From cppreference.com Optional single ...
0
votes
0answers
376 views

c/c++ disassembler for emacs and objdump

I'm trying to show assembly under the cursor in emacs (spacemacs, on mac os x) and although disaster.el does generate assembly with objdump, it fails to associate lines in source with lines in ...
3
votes
0answers
56 views

Working around preprocessor blocks

I am trying to navigate a C project that has lots of preprocessor directives like this: #ifdef SOME_COMPILE_TIME_VARIABLE for ( idx=0; idx<FOO; idx++ ) { #else for ( idx=0; idx<BAR; idx+...
8
votes
1answer
4k views

Best C++ indexer?

I've recently switched over from Eclipse CDT to Spacemacs with the C++ layer as my development environment. So far... awesome! However, one of the things I miss about Eclipse is its indexer. At the ...
1
vote
0answers
316 views

Code completion for C++

I have just started using emacs, after coming from using Xcode. I would like to get code completion for C++, however there are a whole bunch of things that don't really explain what they do (at least ...
4
votes
1answer
197 views

Weird indentation behavior in C++ mode

In C++ mode there is the following behavior of the indentation: Why is this happening? How can I fix it?
1
vote
0answers
175 views

company-mode on Windows partially completes

I installed LLVM on my Windows machine. And now I want Emacs tools to use it. I changed company-clang-executable to "path/to/LLVM/bin/clang.exe". Now I think it finds Clang but somehow completions ...
1
vote
0answers
914 views

Enable Irony-mode

I'm having some trouble trying to activate irony-mode. So i followed the steps: My version of gcc is 5.3.0 so I installed -> clang 3.7.1 I installed CMake Then irony from MELPA After that added this ...
1
vote
1answer
1k views

Turn on semantic mode for C/C++

I got these lines: ;; turn on semantic (semantic-mode 1) ;; define a function which adds semantic as backup to auto-complete (defun my:add-semantic-to-autocomplete() (add-to-list 'ac-sources 'ac-...
0
votes
1answer
361 views

How to make the tab key act normally in C++ mode?

I'm switching over to Emacs as my C++ editor, and what I miss the most is when I use tab, it would write 8 spaces, I could use tab more than once and use it in the middle of code, when I pressed back ...
3
votes
1answer
486 views

Is it possible to use mozilla's rr with gdb multi-window?

I have started using mozilla's rr (timetravelling debugger, github here) on the command line for debugging c++ code. In emacs I can start it with gud-gdb and writing rr replay (as mentioned here or ...
1
vote
2answers
190 views

`M-x` compile always runs the same command

I'm a very new user (~ 2 days) to Emacs. I switched from vim, because it wasn't working for me. I'm learning C++ and I've run into this issue when I write M-x compile. Upon writing this command, emacs ...
3
votes
1answer
5k views

How do I get company mode to recognize clang?

My current setup is as follows Elementary OS Freya Emacs version 24.5.1 company-mode 0.8.12 clang-3.5-dev libclang-3.5-dev I've checked that both libclang-3.5-dev and clang-3.5-dev are installed ...
0
votes
1answer
2k views

How to configure flycheck (c/c++-clang) to ignore some files or directories?

My C++ code use third-party library, so I have to add the library path to flycheck-clang-include-path to avoid can't find header file error. But I don't want flycheck to do the syntax check on that ...
0
votes
2answers
898 views

C++ indentation after member initialization list

When I add a member initialization list to my class constructor, Emacs indents the body like this: Vector::Vector(int s) : elem{new double[s]}, sz{s} { } I expect it to be indented the same ...
1
vote
2answers
937 views

How to set up hotkey for compiling c code and run the compiled file?

I used to use tmux with vim to write codes in C/C++. So I split the screen into two in tmux and then press F3 to "make" the file. And then I can press F4 to run the "main" file in the next subscreen. ...
2
votes
2answers
3k views

Better syntax-higlighting for member variables and function calls in cpp-mode

In atom, C++ files are well colored unlike emacs cpp-mode. Emacs does not highlight references to member variables, function calls or member functions. They all are uncolored. The left is from emacs ...
1
vote
1answer
209 views

How to reduce enum definition indentation?

With my actual configuration, an enum definition looks like this: enum Toto { foo, bar } Spaces are by packs of 4 instead of 2 because I set 4 as default indentation space ...
11
votes
2answers
4k views

How to get semantic syntax highlighting on emacs for C/C++ code

I'm new to emacs and programming in general so please bear with me. I'm trying to use emacs as my C/C++ IDE, and I noticed that in CC mode the variables/functions seemed to be highlighted only during ...
11
votes
1answer
739 views

Color declared variables

I'm looking for a simple way to make emacs remember of declared variable in a single function in C/C++. By "simple", I mean without any external package, just with some elisp lines in configuration ...
4
votes
0answers
2k views

Support C++11 syntax in c++-mode

I want correct indentation with my C++ code. The following piece of code indents properly. It nicely indents the access label and the member declaration independently. class Test : public Base { ...
1
vote
1answer
129 views

C++ inconsistent foreground colors

I have started programming in C++ recently and have been testing using classes. What I have noticed is that if I declare a variable before my methods like: class Test { int value; public: int ...
9
votes
1answer
578 views

disable specific warning in flycheck (specifically “#pragma once in main file”)

I'm using flycheck for C++ development, and get the following warning: #pragma once in main file In all headers included in a main file. Searching the webs, I get the impression this has something ...
3
votes
0answers
150 views

Class inheritance tree in ECB

I'd like to see the inheritance tree for classes which I have currently open, similarly to how it ECB shows related files (e.g. I have a class B in my buffer, its parent A and child C are in different ...
0
votes
0answers
322 views

Non-Indentation of only C++ comments in C++ mode

How can I configure my ~/.emacs so as to get the following effect? In C++ mode, I want C++ comments (but not C-style comments), to always be unindented, i.e., the double slashes should always be ...
2
votes
2answers
1k views

Enable Emacs to suggest the available methods of a class

I have setup Emacs to work almost like an IDE but I haven't managed to make it suggest the available methods of every class. I currently write in C++ and previously I was using Visual Studio so when ...
2
votes
3answers
463 views

Changing or adding compiling options in cc-mode

In cc-mode, when we go to compile, M-x followed by compile, the default option is make -k. If I hit the down arrow, I am told no defaults available. Is it possible to add the option g++ -Wall ...
0
votes
2answers
2k views

Configuring yasnippet and autocomplete to work with C/C++ headers

My computer system and set up are OS: Arch Linux 64bit emacs version: 24.4 alias emacs='emacsclient -t -s server --alternate-editor=' Update: auto complete is working with yasnippet occasionally ...
0
votes
0answers
470 views

Wrong indent in c-mode and c++-mode

In my coding style tabs used to indent and spaces for align. I've configure Emacs for this, but some times emacs places 4 spaces instead of tabulation in some blocks of code. If can be fixed by ...
3
votes
1answer
2k views

setting up irony-mode json compilation database

I am struggling with the setup for irony-mode's JSON cdb support. I have this in my initialization: ;;; C++ code completion (eval-after-load 'company '(add-to-list 'company-backends 'company-irony)...
9
votes
2answers
2k views

Is there a yasnippet producing a prepopulated doxygen comment?

For the following C++ function: bool importantStuff(double a, double b); It should output the following snippet, perhaps without the tags: /** * <Insert description of importantStuff> * * @...
2
votes
2answers
1k views

C++ Incorrect Enum Indentation

It seems like cc-mode indentation is working rather well, however I seem to have run into a minor issue when creating a few enums in C++. Emacs seems to handle almost all kinds of enums rather well ...
1
vote
2answers
554 views

Linking to c++ libraries in babel code block

The title says it all, and I've included the relevant sections of my file below. I'm trying to create a src block that uses some functionality of the boost libraries, the first src block sets up the ...
1
vote
1answer
2k views

Customizing a default indentation style for C++

I use the default style linux (snippet from here) ;; set indentation style linux for c++ (setq c-default-style "linux" c-basic-offset 4) But I can't get it to work with the style setting ...
1
vote
2answers
413 views

helm-semantic-imenu doesn't identify pointers and references in C++ code

With semantic-mode enabled and reading a C++ source file in cc-mode, running helm-semantic-or-imenu correctly shows all the classes, variables and functions defined in that file. However, all the ...
6
votes
2answers
873 views

Change the way CC-mode font-lock the C++11 `auto` syntax

With C++11, the keyword auto attained a new syntax and semantics. However, it seems that CC-mode has not been aware of this. For example, if I write auto var = exp, I get var in green, in which ...
4
votes
2answers
635 views

CC-Mode - Javadoc Comment Colors in C/C++

I've been fiddling around a bit with CC-mode lately and figured that since I prefer to comment my functions/classes with javadoc-like syntax, I'd like to use the built-in comment highlighting provided ...
11
votes
3answers
2k views

How can I get C/C++ context-sensitive completion with Company?

Semantic seems to be able to do this, but I cannot get it to work as I would expect it to. For example, if I #include "Type.h" and declare Type t, using semantic-complete-analyze-inline when point is ...