Questions tagged [c++]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
38 views

c++-mode-map does not stay empty after (setq c++-mode-map (make-sparse-keymap))

I don't like all the major mode bindings. So I usually just (setq the-map-in-question (make-sparse-keymap)) each time I come across a new major mode. But for c++-mode-map, it does not remain empty. I ...
user avatar
  • 37
0 votes
0 answers
30 views

Disable clang-tidy fix on save

It took me about 3 hours to track down what I thought was a bug in my code one very late night. It turn out some layer in spacemacs was accepting the clang-tidy fixes on and writing them out on save. ...
user avatar
  • 129
0 votes
1 answer
31 views

Disabling auto identation when saving a file

I'm using Doom Emacs (pretty much vanilla with a few packages) and whenever I save a file, Emacs automatically changes the indentation. For example, if I'm editing a C++ file like this: FoamFile { ...
user avatar
0 votes
1 answer
62 views

dap-mode cpptools gives error `VTerm needs module support`

I am trying to use dap-mode to debug my C++ code. My debug template looks like: (dap-register-debug-template "cpptools::Run Configuration" (list :type "cppdbg" :request ...
user avatar
0 votes
1 answer
24 views

how to fix / workaround wonky emacs auto-indenting of some C++

See the below. I have two definitions of a floating point array. The latter is valid with C++11. The first one is auto indented in a sane fashion. The second one looks like emacs just doesn't know ...
user avatar
  • 345
0 votes
0 answers
41 views

Hiding Lsp UI Sideline but retaining actions

I am just starting to explore the LSP configuration options. But i am facing very annoying problem with lsp-ui-sideline. I like the options that it provides but hate that it shows up right next to my ...
user avatar
1 vote
1 answer
31 views

Point to bound variables in scope

So, Dr. Racket has a very interesting feature where you can see all occurrences of a bound variable if you hover it: Is there a way to do something similar in Emacs? I'm currently editing C++ code. ...
user avatar
  • 113
0 votes
0 answers
40 views

incorrect c++ enum indentation in emacs 26.x

My emacs 26.3 insists on a very strange enum indentation even when started with --no-init-file --no-site-file class A { public: enum EnumWithLongName { val0, ...
user avatar
  • 111
1 vote
1 answer
42 views

Syntax highlighting in C++ fails in user-defined literals

The C++11 way to separate the parts of a user-defined numeric (integer or floating point) literal with ' as e.g. in 1'500ms stalls parsing for syntax highlighting. I couldn't find anything on the net ...
user avatar
0 votes
1 answer
41 views

What part of emacs displays parent folders at the top and how can I fix their symbols

I updated spacemacs and all layers/ packages today. Since then, when in c++-mode at the top of my buffers the current file and its parent folders are displayed, as shown in the image. I'm fine with ...
user avatar
  • 11
2 votes
1 answer
158 views

Emacs not indenting enum / enum class contents

I've got a small problem to do with Doom Emacs / Emacs. Enum contents are not indented at all... Here's what I would like: enum class RandomEnum { A, B, C, D }; Here's what I get: ...
user avatar
  • 23
0 votes
0 answers
51 views

How to print a separator line at an specific location in the results of a `#+BEGIN_SRC` block whose language is C++?

The context In #+BEGIN_SRC blocks whose language is Python, I can show a separator line in the table that shows the results by using None (see example below) #+begin_src python :results output table ...
user avatar
  • 487
1 vote
0 answers
55 views

Semantic Idle Service Error semantic-idle-summary-idle-function

Context Hey, I've discovered semantic and how useful it is when writing coding, it provides some handy features. I'm mostly using it for C/C++ programming, although there's a bug that kept on showing, ...
user avatar
  • 121
0 votes
1 answer
41 views

Make output of source code blocks be inserted regardless of the exit status of the evaluation

The context When evaluating the following code block, the output is not inserted in the #+RESULTS code block. This happens because of the return 1 statement. #+begin_src cpp :results output #include &...
user avatar
  • 487
0 votes
1 answer
265 views

C++ lsp-mode: inconsistent behavior between remote and local projects

I've run into a bit of an odd problem trying to use lsp-mode. My problem setup is as follows: I'm working on a C++ project on my computer, and I'd like to be able to use lsp-mode with it. The catch is ...
user avatar
0 votes
1 answer
2k views

C++ Header Autocompletion in Doom Emacs

I have the following init file: :tools ;;ansible ;;debugger ; FIXME stepping through code, to help you add bugs ;;direnv ;;docker ;;editorconfig ; let ...
user avatar
1 vote
1 answer
167 views

C++ mode, indendation confusion

Today I realized something odd that bothers me. Here is a little example of a function I wrote. I am using armadillo, but that is is unimportant. Here, the indentation looks just fine. float GetE0() { ...
user avatar
  • 61
0 votes
1 answer
283 views

Auto insert include guard in cpp header when inside projectile project

I am currently learning C++ and I came across include guards to avoid double inclusion. Now I would like to use the google's style convention like this : // project/src/app.hpp #ifndef ...
user avatar
  • 31
3 votes
1 answer
320 views

How to us a shortcut to add semicolon to end of current line?

Is there a shortcut to add a semicolon to the end of the current line of code? For instance, M-; inserts a comment at the end of the current line of code. Is there anything like that for a semicolon? ...
user avatar
  • 133
1 vote
1 answer
27 views

How to see brief location in the code in C/C++ mode

While editing a long C++ file, I use rtags to jump around. It would be very handy for me to know where I am in terms of where the cursor is relative to the classes-functions. For example, it would be ...
user avatar
  • 746
2 votes
0 answers
196 views

debugging c++ code with dap-mode in Emacs does not display std::variables (e.g., vector, map, etc) correctly. Any idea to solve this problem?

When I debug c++ code in dap-mode with Emacs, the std::variables, such as vector and map, always have values, [0]: std, shown in the local variable area. Does anybody know what is going on? I am on ...
user avatar
  • 21
0 votes
0 answers
63 views

Static function highlighting/locking in C++

In C++ mode, I am finding that static functions are only highlighted when written in the form static ReturnType function_name(args), and not when written ReturnType static function_name(args). Image: ...
user avatar
3 votes
1 answer
2k views

Error running timer ‘lsp--on-idle’: (error "The connected server(s) does not support method textDocument/documentLink

I'm trying to setup C++ IDE on spacemacs. Below are the layers configured . dotspacemacs-configuration-layers '( helm (auto-completion :variables auto-...
user avatar
2 votes
2 answers
454 views

Why does flycheck open a new buffer for error messages?

So I am using flycheck for my C++ projects with this setup: ;; Require flycheck to be present (require 'flycheck) ;; Force flycheck to always use c++11 support. We use ;; the clang language backend ...
user avatar
  • 171
0 votes
1 answer
118 views

How to align operands in c++-mode?

I'm trying to get Emacs to align operands vertically. Current behaviour #include <iostream> void main() { std::cout << 1 + 2 + 3; return 1 + 2 + 3; } Wanted ...
user avatar
  • 105
1 vote
1 answer
56 views

Different indentation in files with same modes

My .cxx files have 8-character indentation, while .cpp files have 4-character one. They have exact same modes enabled: My auto-mode-alist has the following c++ lines: ("\\.ii\\'" . c++-mode) ("\\.h\...
user avatar
1 vote
1 answer
608 views

Passing arguments to dap-mode (c++)

everyone. I am new to debugging with dap-mode and i can't figure out how to pass arguments. I tried by creating a template (dap-register-debug-template "GDB::Mine" (list :type "gdb" :...
user avatar
  • 11
0 votes
0 answers
40 views

Why certain rebind keys doesn't work in c++ mode?

I've recently started using emacs and wanted to customize the editor. So, I've tried to rebind certains keys, but It's doesn't to work no matter what I do. (global-unset-key (kbd "C-c") ) (global-set-...
user avatar
7 votes
0 answers
3k views

How to debug C++ (dap-mode + LLDB or GDB)

I want to use dap-mode to debug a C++ code. Until now I followed instructions dap-mode (LLDB) and lldb-vscode. I further enabled the mode and UI via (dap-mode 1) (dap-ui-mode 1) When I execute dap-...
user avatar
  • 223
1 vote
0 answers
31 views

Search for functions by type signature

Is there a convenient way to search through a C/++ codebase and list all the functions with matching type signatures? I'm working in a codebase that makes heavy use of function pointers. ...
user avatar
1 vote
0 answers
13 views

How do you fix a large list of unknown files in Ebrowse?

I'm trying to use the emacs Ebrowse tool. The issue I'm having is a great majority of the C++ files, from my BROWSE file, are showing up as (unknown) file type, resulting in me being unable to open ...
user avatar
0 votes
0 answers
59 views

Stepping through c code in emacs

I am trying to step through code in emacs and am looking for a plugin which will displa the contents of an element when I hover over it. Is there any plugin like this currently? How do you step ...
user avatar
  • 1
1 vote
0 answers
238 views

How do you guys use doxygen? [closed]

I'm curious about Doxygen, how do you guys manage documentation in C/C++ projects on emacs? I didn't find a good package that does it consistently. So far I did use gendoxy and doxymacs. I had ...
user avatar
1 vote
0 answers
52 views

Is there a package that show the value of constant variables? C/C++

I would like some package that show the variable value when I put cursor on it. The behavior that I expect can be seen in the image below. The image below is in vscode, I would like some package that ...
user avatar
0 votes
1 answer
229 views

How to hide header line in C++ mode?

I really don't want emacs to show me which function the pointer is currently inside. (See the photo) What is the name of that frame? How can I remove it or make show an empty line? I am using Emacs ...
user avatar
  • 103
1 vote
0 answers
127 views

How to fix indentation of C++ methods with ref-qualifiers?

Emacs in its default configuration seems to have trouble indenting C++ methods with reference qualifiers (& and &&). For example: struct foo { void a_method() && { ...
user avatar
2 votes
0 answers
336 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?
user avatar
  • 389
0 votes
1 answer
372 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 ...
user avatar
  • 337
4 votes
1 answer
360 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 ...
user avatar
  • 1,019
2 votes
1 answer
97 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() {}
user avatar
  • 165
2 votes
1 answer
168 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 ...
user avatar
7 votes
1 answer
8k 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-...
user avatar
0 votes
0 answers
153 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 ...
user avatar
  • 731
1 vote
0 answers
423 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 ...
user avatar
  • 389
1 vote
1 answer
168 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>......
user avatar
1 vote
0 answers
235 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 { ...
user avatar
  • 21
0 votes
2 answers
208 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 ...
user avatar
  • 269
3 votes
1 answer
716 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?
user avatar
1 vote
1 answer
227 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; } ...
user avatar
  • 13
2 votes
0 answers
563 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 ...
user avatar
  • 277