Skip to main content

Questions tagged [c++]

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

Filter by
Sorted by
Tagged with
0 votes
2 answers
40 views

While editing C++ code, using lsp, how do I display function prototypes?

I am using emacs with clangd lsp setup. In the status bar, function prototypes are displayed as I enter code, which is very convenient. However, sometimes there are different versions of a function ...
user52366's user avatar
  • 141
1 vote
0 answers
19 views

Add preprocessor like prefix for C/C++ indentation

I want to extend the existing indentation capabilities for macro constructs which behave like preprocessor directives. Consider the following code example: void fkt() { const int a = 0; MY_MACRO(...
theldoria's user avatar
  • 1,845
0 votes
1 answer
42 views

Better accuracy syntax highlighting

So I spent a bit of time making my own theme for emacs since none of them were quite right for me, and I'm really loving it as a text editor, but I'm wondering if there was a package that would give ...
Alex's user avatar
  • 1
0 votes
0 answers
15 views

Projectile test jump to failed test using gtest

I have projectile setup on a meson built cpp-project. I can compile and test via projectile just fine, i.e. projectile calls ninja and navigates the errors, warnings in the results. But the test ...
user92020's user avatar
1 vote
1 answer
24 views

C++, arglist-intro indent based on the indentation of previous line?

Consider the following C/C++ code { auto x = f(g(h( "aaa"))); } The "aaa" is indented this way, because c-offset-alist has (arglist-intro . +) (I think ...
MetroWind's user avatar
  • 187
0 votes
1 answer
35 views

Unexpected (lack of) indentation in C++ end-of-line comments

When using C++ mode I've noticed that the tab key indents the current line. However, if I'm at the end of the line, I would like to be able to use tab to add aligned whitespace so that I can add // ...
finitud's user avatar
  • 101
1 vote
0 answers
188 views

C++17 with LSP and Flycheck

lsp-mode is working correctly. flyecheck is working correctly, with the exception of regonizing some c++17 features. #include <map> std::map<int,int> magic; magic.try_emplace(1,1) // ...
Tiago Matos's user avatar
0 votes
1 answer
163 views

Can someone help me with lsp C++20 features recognition?

Lsp clangd does not recognise c++20 features in my Emacs. I use flycheck and it highlights something as import <iostream> std::format is not supported either and so on. Can someone tell me how ...
weuoimi's user avatar
0 votes
0 answers
53 views

Syntax highlighting C++ variable names that contain a $ sign

Many C/C++ compilers have a nonstandard extension that allows $ to appear in variable names. In c++-mode, if I write int main() { int $a = 0; } Then $a doesn't get colored like a variable name, ...
Joseph Garvin's user avatar
3 votes
2 answers
2k views

C/C++ with tree sitter: how to change indent?

I use Emacs with tree sitter for c++ code (c++-ts-mode). With usual c++-mode I've used this fix for me: (c-set-offset 'inline-open '0) but I don't understand how to do it in new c++-ts-mode. In ...
Sergey's user avatar
  • 243
0 votes
2 answers
199 views

overview of functions, methods within a file

I would like to have an overview of all functions/methods/classes/namespaces defined within the currently open file (.cpp or .h). Just like this is the case in VSCode and in Intellij (called "...
dgan's user avatar
  • 153
0 votes
0 answers
48 views

Run clang-format in org source block

I have some org files with cpp source blocks. I want to format the code in the source blocks using clang-format. Consider this complete org file: This is a test: #+begin_src cpp struct Foo ...
Lukas Barth's user avatar
0 votes
0 answers
252 views

C++ code in doom mode is shown as errors

I've C++ file written in style c++17 opened in doom emacs. Below is the contents of the file. #include <iostream> #include <string> using namespace std; int main() { int arr[] { 1, 2, ...
Rajkumar Natarajan's user avatar
0 votes
1 answer
98 views

Babel C++ blocks have incorrect indentation

When using a C++ source block in org-mode, the indentation doesn't match that of the C++ major mode. Viewing the source block in the org file: Viewing the same code in a C++ mode buffer or using org-...
dag-h's user avatar
  • 1
1 vote
1 answer
126 views

How to set up K&R everywhere (1TBS) brace style in cc-mode?

I'd like Emacs to follow this indentation style: struct Foo { void bar() { for (int i=0; i<10; i++) { if (condition) { // code // code ...
sajmon's user avatar
  • 56
0 votes
0 answers
337 views

Emacs moves curly braces -- how to stop

I have the "bsd" style selected for C++ programming but when I go to define a function and enter the curly braces on the new line this happens: Press RET Is there any way to stop this ...
osilverstone96's user avatar
0 votes
0 answers
997 views

"Error running timer file missing doing vfork" Emacs dap debug C++

I've c++ cmake project beginning-cpp20. The project structure as as below - $ tree . . ├── CMakeLists.txt ├── launch.json └── meetingcpp.cpp The contents of CMakeLists.txt is - cmake_minimum_required(...
Rajkumar Natarajan's user avatar
1 vote
2 answers
110 views

How to execute Elisp code embedded in c++ comment?

While I found lots of sources, how to use Elisp in an org-mode document, what I try to do is not related to org-mode at all. My idea is to embed Elisp functions and calls of Elisp functions within ...
BitTickler's user avatar
0 votes
1 answer
83 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 ...
Alan's user avatar
  • 37
0 votes
1 answer
234 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 { ...
riedaug's user avatar
  • 43
0 votes
1 answer
207 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 ...
Lucas Myers's user avatar
0 votes
1 answer
110 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 ...
Vince W.'s user avatar
  • 425
1 vote
1 answer
55 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. ...
Romário's user avatar
  • 143
0 votes
0 answers
68 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, ...
zzz777's user avatar
  • 111
1 vote
1 answer
70 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 ...
Vroomfondel's user avatar
0 votes
1 answer
52 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 ...
Eike's user avatar
  • 111
2 votes
1 answer
275 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: ...
Krys's user avatar
  • 105
0 votes
0 answers
92 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 ...
doltes's user avatar
  • 587
1 vote
0 answers
127 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, ...
0x0584's user avatar
  • 121
0 votes
1 answer
53 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 &...
doltes's user avatar
  • 587
0 votes
1 answer
510 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 ...
pipsqueaker117's user avatar
0 votes
1 answer
3k 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 ...
finite_diffidence's user avatar
1 vote
1 answer
288 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() { ...
Andi's user avatar
  • 81
0 votes
1 answer
575 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 ...
johhnry's user avatar
  • 31
3 votes
1 answer
783 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? ...
mrbean's user avatar
  • 133
1 vote
1 answer
41 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 ...
yujaiyu's user avatar
  • 896
2 votes
0 answers
305 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 ...
Jeff's user avatar
  • 21
0 votes
0 answers
96 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: ...
J. Jaksche's user avatar
4 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-...
Rajkumar Natarajan's user avatar
3 votes
2 answers
892 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 ...
choeger's user avatar
  • 191
0 votes
1 answer
198 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 ...
tastytea's user avatar
  • 105
1 vote
1 answer
93 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\...
honey_badger's user avatar
1 vote
1 answer
1k 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" :...
das's user avatar
  • 11
0 votes
0 answers
63 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-...
Marco Vinicio's user avatar
7 votes
1 answer
4k 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-...
DrDirk's user avatar
  • 223
1 vote
0 answers
48 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. ...
Koala Bear's user avatar
1 vote
0 answers
19 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 ...
Joe Plumber's user avatar
0 votes
0 answers
76 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 ...
pluto's user avatar
  • 1
1 vote
0 answers
416 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 ...
Lucas Peixoto's user avatar
1 vote
0 answers
56 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 ...
Lucas Peixoto's user avatar