Stack Exchange Network

Stack Exchange network consists of 175 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

0
votes
1answer
22 views

cmake-ide defining variables

I have a project I build using cmake. To build this project, I need to define several options like -DPRODUCT=amd64 -DXML_DIR=/opt/xml_database Normally, I either pass these as -D or configure them in ...
2
votes
0answers
33 views

Valgrind interface for emacs

Is there an interface similar to 'gdb-mi' for using Valgrind in emacs? What are some ways to use Valgrind inside emacs?
1
vote
0answers
24 views

Is there a way to disable multi-line string literals in c++-mode?

Suppose I have a short string in C++ and I accidentally delete the double quote that ends it. What Emacs does is highlight the rest of the code as a single very long string, which messes up all the ...
2
votes
1answer
53 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 ...
2
votes
1answer
32 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
550 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-...
0
votes
1answer
772 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
168 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" ...
1
vote
2answers
566 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 ...
11
votes
1answer
632 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
87 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
25 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
222 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
95 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
65 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
vote
0answers
77 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
45 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 ...
1
vote
1answer
87 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
172 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
97 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
111 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
663 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
176 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
852 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
148 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
400 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
216 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
247 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
47 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....
3
votes
2answers
4k 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'...
2
votes
0answers
865 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
1answer
56 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
38 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
420 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
321 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
320 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
16 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
980 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
769 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
641 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!
43
votes
6answers
52k 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
1k 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
139 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-...
0
votes
3answers
4k 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
875 views

Flycheck: How to disable c++11 Warnings?

I am using flycheck with its defaults to write modern C++ code. I frequently get warnings such as: extended initializer lists only available with -std=c++11 or -std=gnu++11 when using modern ...