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
26 views

autofill a cpp file based on the .h file

suppose I have x.h class X { void f(); void g(); } in x.cpp #include "x.h" can I just entry a command with "X" as a parameter, then I can get void X::f() {} void X::g() {}
2
votes
1answer
154 views

lsp-mode: How to use built-in clangd client?

I'm trying to use lsp-mode (together with company-lsp) for auto completion in C++. According to the docs[0], recent lsp-mode includes clangd support, so I should be all set when I do (require 'lsp-...
1
vote
1answer
34 views

Emacs indents C++ functions in structs in an unexpected way

Emacs indents functions in structs in the following way: struct A { int a() { return 1; } int b() { return 2; } } int c() { return ...
0
votes
1answer
717 views

Building targets using cmake-ide

I switched to emacs as my C++ ide. I am using irony mode, company, rtags, and since all of my projects are using cmake, cmake-ide. I cant realy find something online on how the workflow works with ...
1
vote
1answer
153 views

trouble with flycheck-gcc-language-standard variable

I am attempting to use Directory-Variables in order to set the flycheck-gcc-language-standard variable. I used: M-x add-dir-local-variable RET c++-mode RET flycheck-gcc-language-standard RET "c++11" ...
0
votes
0answers
215 views

Indentation after cout in C++ mode

I have a problem with indentation after: cout << "...." ....; lines in c++-mode. Expected cursor position after pressing Enter is the next line and column is right under cout. But as you may ...
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 ...
7
votes
2answers
3k views

Class Browsing in C++

I'm working with a large codebase and often find it to be tedious and hard to understand class relationships. I found the following wiki that describes various tools for working with OOP in C++, but ...
9
votes
1answer
575 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 ...
0
votes
1answer
74 views

CEDET semantic-complete-jump customization

When I search through project via semantic-complete-jump and tag is not unique (its defined in multiple places), I must hit <tab> to iterate through all possible places. Problem is, I horribly ...
0
votes
0answers
23 views

Too much time spent for emacs to open cpp in the project

I use ggtags in order to improve my efficiency. I follow the manual to setup emacs environment. https://tuhdo.github.io/c-ide.html However, during editing the cpp files in the projects. Chance are ...
1
vote
2answers
195 views

Org-babel. :flags in C code blocks dont work correctly anymore

I'm trying to run current code block #+HEADERS: :includes <math.h> <stdio.h> :flags -lm #+HEADERS: :var x=1.0 :var y=4.0 :var z=10.0 #+begin_src C :tangle trying double pi = 4*atan(1); ...
1
vote
0answers
51 views

Tools for refactoring c++ code

What tools do you use to refactor c++ code? For example, how do you rename a variable or function that is spread across files? If the problem isn't language specific, there are text-based tools that ...
1
vote
1answer
49 views

Problem debugging in `gud-mode' (M-x `gdb' with `many-windows' enabled)

I'm debugging a large codebase (written in C++). Everything works perfectly if I run gdb from a regular terminal as follows: $ gdb <program-name> Reading symbols from <program-name>......
-1
votes
0answers
35 views

Flycheck C++ “to_sting” not found

If I try // to_string example #include <iostream> // std::cout #include <string> // std::string, std::to_string int main () { std::string pi = "pi is " + std::to_string(3....
1
vote
0answers
59 views

c++ mode indentation

If we have a class like the one below emacs is indenting the : (to the initialization list). To be able to match some other editor, is it possible in emacs to indent the : like below? class Test { ...
0
votes
2answers
37 views

How to configure C-M-q and TAB key to expand pre-existing TAB characters into spaces in C/C++ files

In C and C++ files, I want to configure the mode so that any time I request indentation, that it will always expand all of the embedded TAB characters in indentation (at the start of the line, and no ...
0
votes
0answers
26 views

C++ Flycheck and the include-template-impementation-in-header trick

I'm running emacs 25.3.2 with a current flycheck installed. Flycheck uses clang-5 as a checker for C++. I like to keep my declarations and definitions separated in two files even when working with ...
1
vote
1answer
60 views

What does the `/l` mean in the mode `C++/l` mean?

Just a simple question with more than likely a simple answer: What does the /l mean in the mode C++/l mean?
1
vote
2answers
145 views

What is the good resource for getting started using EMACS? [duplicate]

I have not used EMACS seriously in 20 years. I work on a Mac and am a vi/Eclipse person now. I want to switch back to EMACS for C and C++ programming. When I was researching EMACS add-on packages ...
4
votes
1answer
93 views

Globally set C++ source block header arguments

I try to globally set header properties for C++ source examples, with no success. I would have expected that the following works #+PROPERTY: header-args:C++ :var x=1.0 What did work is using ...
1
vote
1answer
94 views

Show constructor arguments for c++

Is there a package that can tell me the arguments for c++ constructor? class T1 { public: T1(int x, int y); }; T1::T1(int x, int y) { std::cout << x+y << std::endl; } ...
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 ...
2
votes
0answers
149 views

Navigate C/C++ Source Code with Emacs [closed]

So, i'm finally starting to work with a multi-file Project in C++ and am in need for smart navigation and completion! So far, i've used company-mode (with irony and company-headers), which is great if ...
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
131 views

How to tell Emacs where h or hpp header file is, in cpp mode?

My .cpp file is not in the same folder as the h or hpp file. therefore #include "../../.." in the cpp file is underlined. My question is: How do I tell Emacs where to look for the header file?
0
votes
0answers
375 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 ...
6
votes
2answers
200 views

C++ mode: smartly use /*…*/ for comment-dwim

I want to adjust the behavior of comment-dwim when editing c++ files: When a region is selected that either starts or ends in the middle of a line I would prefer /* ... */ comments. For the other ...
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 ...
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 ...
1
vote
1answer
192 views

Extra indentation for argument lists beginning on a new line

I'm fine-tuning my C++ style using c-add-style, but I've reached an impasse where I cannot convince Emacs to (extra) indent arguments where the first argument starts on a new line. When I'm forced to ...
0
votes
0answers
73 views

Debugging with gdb does not allow user to enter multiple console inputs

I wrote the following C++ program in Emacs named check_emacs_debug.cpp #include <iostream> int main() { for(int i = 0; i < 10; ++i) //Breakpoint { int num; std::...
0
votes
0answers
42 views

How to indent c++ “special” source lines that don't end with semicolons

I'm working with a system that uses special macros a lot. For instance: class UDSSLib : public UFunctionLibrary { GENERATED_BODY() void foo(); int i; } The problem is the GENERATED_BODY() line....
1
vote
2answers
3k views

How to compile and run a C++ file? [closed]

I don't know how to compile and run a C++ file in GNU Emacs. I searched on the various sites and stackexchange network, but from them what I understood was write something like make compile, and I don'...
1
vote
0answers
729 views

Spacemacs C++ debugging?

What tools are you using for setting Breakpoints visualize Variables within Spacemacs? I had a look at gdb but it felt awkward to set the breakpoints separated from the source files. I would like to ...
0
votes
0answers
151 views

Autocomplete fails when adding C++ standard header files

I want both autocomplete support for C++ keywords and C++ standard headers. In other words, I want A keyword like while to be autocompleted. An expression like #include <iostream> to be ...
0
votes
1answer
51 views

Is it possible to retain outline overlay when switching modes

I want to switch between org-mode and c++-mode on top of a single file. I use org-mode syntax inside c++ comment blocks. In Org-mode I have foldable sections while in c++-mode I use hide/show for ...
1
vote
0answers
36 views

Hide region from syntax highlighting and indentation

c++-mode does not handle the C++17 R"delim()delim" string literals. Is there a way to mark a region (via comments?) so it will not be syntax highlighted and will not confuse the indenter?
3
votes
2answers
396 views

automatically close type parens in C++

Does anybody know of a way or a package that can recognize < and > when occuring in template contexts and automatically writes a > either right after the < or after the selected region ...
1
vote
0answers
293 views

Emacs c++ cannot use semantic and company-semantic to complete <string> library function

system: linux mint 18.1 Eamcs version: 25.2 semantic configuration: (global-semanticdb-minor-mode 1) (global-semantic-idle-scheduler-mode 1) (semantic-mode 1) create a cpp file and include vector,...
8
votes
1answer
282 views

formatting constexpr if in c++-mode

I recently started using C++17, which brings constexpr if. This however screws up c++-modes default indentation. // emacs 25.3.2 with --no-init if constexpr (n == 1) { // Why? } else if ...
1
vote
0answers
15 views

Personalize indentation for new C++ language features [duplicate]

I'm starting to use C++-17, and one of the new features is if constexpr, which breaks completely the usual if identation: int main() { if constexpr(true) { return 1; } else { ...
1
vote
2answers
889 views

How to run C/C++ code in Org Babel?

I'm trying to execute C and/or C++ snippets in Org Babel. For example, I want to be able to execute the following snippet with C-c C-c: #+begin_src C printf ("Hello World!"); #+end_src The ...
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 ...
2
votes
1answer
601 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
1answer
39 views

Linking Multiple Implementation Files in C on Emacs

I need help with linking multiple c source code files on emacs. Could anyone show me the way on how to work this out? Thanks!
40
votes
6answers
51k views

How to get intelligent auto-completion in C++?

Emacs cannot compete with another other IDE if it doesn’t have an auto completion function. Auto-complete simply makes me a more efficient programmer. I know of the Auto Complete Mode extension, but ...
-1
votes
1answer
973 views

Auto format messy code

I am currently learning C++ and I am in the process of configuring Emacs as my C++ IDE. I am reading a PDF guide and copying code into my Emacs buffer. However upon pasting the code the formatting is ...
1
vote
1answer
132 views

Why do multi-line comment blocks influence C++ indentation?

I'm a long-term Emacs user who recently started to learn C++. I was surprised to discover that indentation for C++ is actually rather bad, specifically in files containing multi-line comment blocks. ...
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-...