Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [c]

is for C source code editing, completions, formatting, compiling, folding, searching, executing, syntax checking, debugging, and other modern IDE features that Emacs supports.

43 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3 votes
0 answers
428 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?
hrkrshnn's user avatar
  • 439
3 votes
0 answers
156 views

Working around preprocessor blocks

I am trying to navigate a C project that has lots of preprocessor directives like this: #ifdef SOME_COMPILE_TIME_VARIABLE for ( idx=0; idx<FOO; idx++ ) { #else for ( idx=0; idx<BAR; idx+...
nispio's user avatar
  • 8,235
3 votes
0 answers
169 views

Turn C Electric Indentation off only for specific characters

Extending Customizing c-mode indentation behavior in emacs-24.4 How can electric indentation be disabled for other specific keys without disabling the entire mode? Specifically, how can electric ...
user2127595's user avatar
2 votes
0 answers
103 views

How to modify behavior of syntax highlighting without editing the original source?

There is a bug in C/C++ comment highlighting (bug 11865) Where the fix appears to be to modify the value of c-font-lock-doc-comments Is there a way to do this in my emacs config, instead of having ...
ideasman42's user avatar
  • 8,826
1 vote
0 answers
25 views

Customized c-mode indentation style in Emacs 27.2

I would like to produce c code in the following format: char *ft_strdup(const char *s1) { char *h; size_t len; ... } Where I can tab after the type of the function signature and ...
Egydio Pacheco's user avatar
1 vote
1 answer
146 views

Is there a way to display breadcrumbs in C mode in a headerline or another window

I am using emacs (GNU Emacs 25.3.2) on Ubuntu. I was wondering if its possible to display short breadcrumbs or selected compound statement in a headerline (even another window is fine). Probably I am ...
Aval Sarri's user avatar
1 vote
0 answers
53 views

ETAGS with dependencies

I'm trying to use emacs for C development. From here, I understand that in order to see the definitions of functions, I need to use something called etags. My code is: #include <stdlib.h> #...
Mittenchops's user avatar
1 vote
0 answers
29 views

fork in org-mode babel source block executes incorrectly

I have this small piece of code on emacs org-mode : #+BEGIN_SRC C :eval #+BEGIN_SRC C :fork-example1.c :noweb no-export :eval :flags -Wall -Werror -pedantic //Fork-exemplec-cours.c #include <stdio....
Vincent's user avatar
  • 11
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
1 vote
0 answers
149 views

Align elements of a matrix to the right

I have a matrix in C++ Matrix<double> A = { {31, -13, 0, 0, 0, -10, 0, 0, 0}, {-13, 35, -9, 0, -11, 0, 0, 0, 0}, {0, -9, 31, -10, 0, 0, 0, 0, 0}, {0, 0, -10, 79, -30, 0, 0, 0, -...
Mike Manilone's user avatar
1 vote
0 answers
286 views

Is this a c-default-style? If not, how can i configure it?

I've just started using spacemacs and the docstrings for cc-styles are a bit daunting. I've also just started working on a new project in c, and would like to keep consistent with existing style: ...
Aidenhjj's user avatar
  • 111
1 vote
0 answers
251 views

Performance issue of c-mode

When I'm pressing C-p/n moving the cursor around, the redisplaying is quite lagging. A profile of CPU give + command-execute 527 59% - ...
Saddle Point's user avatar
1 vote
0 answers
49 views

annotate C's function list static or not in Speedbar

Is there any way to configure Speedbar to tag functions in the buffer static or extern for C? If not, how can I make it?
Yasushi Shoji's user avatar
1 vote
0 answers
72 views

Parsing non-standard C with gtags

I'm working with a codebase that's meant to be built with a proprietary C compiler using tons of esoteric language extensions. Ideally, I'd like to stick to my chosen environment as much as possible, ...
yafov's user avatar
  • 314
1 vote
0 answers
243 views

Is CEDET/semantic obsolete? How to analyze C code for source transformation tasks?

Reading through some CEDET docs I found that the author herself recommends "to use Semantic only as source of information, and perform names completion using other packages". Does this advice also ...
Vroomfondel's user avatar
1 vote
0 answers
159 views

Structures are defined using a macro, flycheck gives errors

In our source code we surround structures with a macro (MKDIFF) that serves as a flag for the Makefile system. It does not expand into anything, just a flag. Flycheck (understandably) flags these ...
SFbay007's user avatar
  • 584
1 vote
0 answers
157 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 ...
space_voyager's user avatar
1 vote
0 answers
1k views

Why do "gnu" and "linux" `c-default-style` treat `c-basic-offset` differently?

These lines in my .emacs (setq-default indent-tabs-mode nil) (setq-default c-default-style "linux") (setq-default c-basic-offset 4) result in the following formatting of my c code (the c-basic-...
alisianoi's user avatar
  • 111
1 vote
0 answers
203 views

Smarter compile in emacs

I often got to work with projects organized as follows: src/ include/ ... Makefile Is there a way to teach emacs' "compile" function to always use that top-level Makefile regardless which file I'...
god's user avatar
  • 266
1 vote
0 answers
589 views

Code completion for C++

I have just started using emacs, after coming from using Xcode. I would like to get code completion for C++, however there are a whole bunch of things that don't really explain what they do (at least ...
Jonathan.'s user avatar
  • 111
1 vote
0 answers
27 views

How can I have C functions coloured based on whether they are defined?

Colleague of mine showed me a cool feature of gnome-builder which does colour symbols based on whether they are defined or not and I was wondering whether it is possible in Emacs as well. And by that ...
nert's user avatar
  • 213
0 votes
0 answers
11 views

LSP mode connecting to wrong server

I'm trying to read the postgres source code. My lsp server connects to the clangd lsp for some reason even though the project is using C. [-] /home/jenia/git/postgresql `-[-] clangd:40775 |-[-] ...
Jenia Ivanov's user avatar
0 votes
0 answers
22 views

How to use hideshow to fold the `#ifdef`

I use the package hideshow to fold/unfold codes. Recently I write some code to enable folding the #ifdef, #endif in c-mode like that (add-to-list 'hs-special-modes-alist '(c-mode &...
Thysrael's user avatar
0 votes
0 answers
87 views

How to configure Emacs to support indented C preprocessor statements?

In some cases I deal with code that has heavily indented C preprocessor statements and want to setup Emacs to work with it without changing that indentation and follow the same indentation when having ...
PRouleau's user avatar
  • 796
0 votes
1 answer
227 views

flycheck can't find header file even though flycheck-clang-include-path configured

I am using Doom Emacs as my editor for C. I'm trying to use glib in my C project and for that I'm including glib.h. I have added the include dirs displayed by pkg-config --cflags glib-2.0 to flycheck-...
Johnny's user avatar
  • 1
0 votes
0 answers
31 views

Make ff-find-other-file ignore include directive in C

I have a binding setup as described here, the problem is every time the cursor is on #include "file" it always tries to jump on this include. I want that no matter where there cursor is I ...
Yuki's user avatar
  • 111
0 votes
1 answer
96 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
0 votes
0 answers
162 views

When using company and lsp, why does the placeholder text sometimes not get replaced?

In a buffer in c-mode with the following content (with point after retu), pressing enter completes to return expression;. int main(int argc, char** argv) { retu } Point is now at the beginning of ...
ruds's user avatar
  • 143
0 votes
0 answers
170 views

Rewriting paths for bazel

The Bazel build tool has some features that interact poorly with emacs. When you build a C/C++ project for sandboxing purposes it makes a crazy hierarchy of symlinks, and uses them when invoking GCC. ...
Joseph Garvin's user avatar
0 votes
0 answers
28 views

Emacs displays letters and spaces as newlines until a non-letter/space char is entered

I am editing a C file, and it suddenly starts moving to a new line instead of showing the character I typed. This seems to be for letters and space. However, it has saved the characters, and if I type ...
Bill Purvis's user avatar
0 votes
0 answers
14 views

Strange flush left C-code formatting in Emacs 24.3 of SLES 12 SP5

I see some odd Emacs behavior in C-mode recently. I suspect that the change happened either when switching from SLES 12 SP4 to SLES12 SP5 (both have Emacs 24.3), or when switching from SLES 11 SP4 (...
U. Windl's user avatar
  • 215
0 votes
0 answers
287 views

noweb doesn't expand at all

I have a feeling this must be a stupid simple problem however I just can't seem to figure out what I'm doing wrong. I'm using Doom emacs and trying to use noweb with org mode source code blocks to ...
Reginald Marr's user avatar
0 votes
0 answers
55 views

Use iconv directly on the selected region to convert codes

I copied and pasted the C code as: int main(void) {    statements    return 0; } to org's babel code block, when strike C-c C-c, it report error: /tmp/babel-uaYVXU/C-src-Pd1SZs.c:11:6: error: stray ‘...
Wizard's user avatar
  • 1,251
0 votes
0 answers
194 views

Where is M-x compile?

I have a basic C file open in c-mode: #include <stdio.h> #include <stdlib.h> int main() { return 0; }; I'm trying to compile it. I type M-x compile expecting to be asked to set my ...
Mittenchops's user avatar
0 votes
0 answers
75 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
0 votes
0 answers
22 views

some pointer declarations not colored

macs -nw fails to color code certain declarations of pointer arrays seemingly depending on the structure being pointed to. For example: SomeStruct *one[4] is all white (I have dark background), but ...
Thomas Kirven's user avatar
0 votes
0 answers
205 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 ...
yuxuan's user avatar
  • 781
0 votes
1 answer
216 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 ...
dev1223's user avatar
  • 241
0 votes
1 answer
958 views

How to toggle multi-line comment blocks?

Is it possible to configure multi-line comments to comment/uncomment selected text? For example C/C++'s preprocessor could be toggled like this. eg: Before: // a comment Some(code); /* ...
ideasman42's user avatar
  • 8,826
0 votes
0 answers
763 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 ...
Alejandro Erickson's user avatar
0 votes
0 answers
151 views

How to add a key map in Emacs source code?

I found ESC-prefix and Control-X-prefix defined in keymap.c: initial_define_key (global_map, 033, "ESC-prefix"); initial_define_key (global_map, Ctl ('X'), "Control-X-prefix"); But no matter what ...
Sergey's user avatar
  • 243
0 votes
0 answers
90 views

Make Helm Projectile to show external sources

I'm pretty new to emacs (was using Vim), primarily using it for Ruby on Rails projects. At my free time, I like to write some C code for STM32 micro-controllers. Unlike RoR project, C project for ...
Kukunin's user avatar
  • 151
0 votes
0 answers
571 views

Wrong indent in c-mode and c++-mode

In my coding style tabs used to indent and spaces for align. I've configure Emacs for this, but some times emacs places 4 spaces instead of tabulation in some blocks of code. If can be fixed by ...
drmgc's user avatar
  • 1