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() {}
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 ...
2
votes
1answer
164 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
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
0answers
54 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
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
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
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
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 ...
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 ...
1
vote
1answer
61 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
1answer
96 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
0answers
150 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 ...
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?
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 ...
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
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
75 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
0answers
735 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 ...
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'...
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 ...
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?
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 ...
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
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" ...
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 { ...
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 ...
8
votes
1answer
283 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
2answers
890 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 ...
0
votes
0answers
216 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
votes
1answer
984 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 ...
3
votes
2answers
397 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 ...
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!
1
vote
1answer
134 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
0answers
295 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,...
0
votes
1answer
812 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 ...
2
votes
1answer
489 views

Gray-out preprocessor conditionals

Is there a package that will gray out or hide the false portion of a c preprocessor macro? #define ENABLE 1 #if ENABLE bool hide = false; #else bool hide = true; #endif In the above example, ...
0
votes
1answer
195 views

Auto convert dot `.` to arrow `->` in C/C++?

I'm using flycheck in cc-mode and it reminds me when I'm typing: member reference type 'ListNode *' is a pointer; did you mean to use '->'? I want to know if there's any package can convert . ...
0
votes
1answer
335 views

How do you add command line options to flycheck's C++ checker?

I needed to specify stdlib options in a certain environment, so I changed the flycheck executable to clang -std=c++11 -stdlib=libc++, which is needed to compile the file. However, I got the error ...
5
votes
1answer
449 views

Displaying the type of variable in C++ code with cursor

It has been difficult to see immediately the types of variables in C++ codes because they are defined using 'auto', 'template' and 'decltype'. If you use IDE, you can detect the type after the ...
0
votes
0answers
651 views

Flycheck c/c++-gcc doesn't understand C++

I get the following when trying to check a header file; -*- mode: compilation; default-directory: "~/devel/projects/SHARED/" -*- Compilation started at Wed Feb 15 16:06:41 gcc -fshow-column -fno-...
1
vote
0answers
131 views

Should K&R indentation work in C++ code?

Given the following file, named as x.cpp I get the following unexpected indentation behavior: #include <stdio.h> class X { public: X() { // <-- Why the indent? ...
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
0answers
315 views

prog-mode-hook not run for C++ mode

I am trying to turn on linum-mode and fci-mode for C++ editing. Here is my configuration: ;; If non nil line numbers are turned on in all `prog-mode' and `text-mode' ;; derivatives. If set to `...
1
vote
1answer
384 views

Change C indent style for specific project?

I have in my ~/.emacs.d/init.el: (use-package google-c-style ;; provides the Google C/C++ coding style :ensure t :config (add-hook 'c-mode-common-hook 'google-set-c-style)) However, a ...
0
votes
1answer
719 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
0answers
70 views

Getting gdb to work for this project

For this project, I cannot seem to get M-x gdb to work in Emacs 25.1 (on Ubuntu 14.04.5 64-bit if it matters - this should be the case for any Ubuntu-based Linux in general I imagine). Steps to ...
2
votes
1answer
705 views

Jump to definition of function or class in one of the include files?

Take the following sample code: #include <cmath> int main() { double a = -10; double b = std::abs(a); return 0; } When I place the cursor over abs, for example between b and s, I ...
3
votes
1answer
1k views

Enlarge font size of function names in source code like Source Insight

Source Insight can show function names in a larger font. Can Emacs display function names with a larger font and different color?