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.
37
questions with no upvoted or accepted answers
3
votes
0answers
90 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+...
3
votes
0answers
157 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 ...
2
votes
0answers
278 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?
2
votes
0answers
102 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 ...
1
vote
0answers
32 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>
#...
1
vote
0answers
23 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....
1
vote
0answers
47 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 ...
1
vote
0answers
91 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, -...
1
vote
0answers
204 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:
...
1
vote
0answers
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?
1
vote
0answers
55 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, ...
1
vote
0answers
192 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 ...
1
vote
0answers
140 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 ...
1
vote
0answers
126 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 ...
1
vote
0answers
968 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-...
1
vote
0answers
160 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'...
1
vote
0answers
468 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 ...
1
vote
0answers
25 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 ...
0
votes
0answers
13 views
Emacs incorrectly indenting C code when auto-fill-mode is enabled
I have this single line in my ~/.emacs:
(add-hook 'prog-mode-hook 'auto-fill-mode)
Now I open a foo.c with Emacs and type this code. I only type the code
and enter. I do not type any tab. This is the ...
0
votes
0answers
55 views
How to change default shell for Emacs on MS Windows?
I'm very new to Emacs (using Doom Emacs) as a former Vim user, and I've been loving it. However, I've been having issues trying to get irony-server to run. From what little I've been able to gather (...
0
votes
0answers
33 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 ...
0
votes
0answers
87 views
Doom Emacs: Flycheck cannot find header files in gtkmm-3.0
I am attempting to use gtkmm-3.0-dev in a small project. It uses meson as its build tool, and I use ninja to create a compilation database. However, regardless of any variables I set, Flycheck cannot ...
0
votes
0answers
20 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 ‘...
0
votes
0answers
33 views
Aligning the colon in multi-line tertiary expressions in C and C++
Suppose I have the following line
double dx = r1 < 1 ? sqrt(r1) - 1 : 1 - sqrt(2 - r1);
I press enter and tab at the colon causing Emacs to align like this:
double dx = r1 < 1 ? sqrt(r1) - 1
...
0
votes
0answers
70 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 ...
0
votes
0answers
31 views
How to fix indentation of anonymous structures in function argument position in C?
I've been stumbling upon this constantly.
Suppose that I have a function that accepts a structure, or a pointer to a structure:
struct s {
int n;
char c;
};
void f(struct s *s);
I'd like to ...
0
votes
0answers
9 views
Focus ggtags-global when it spawns
When I find definitions ggtags-find-tag-dwim and there are multiple results it opens *ggtags-global* but the focus remains in my buffer that initiated the call to ggtags-find-tag-dwim. I'm trying to ...
0
votes
0answers
54 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 ...
0
votes
0answers
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 ...
0
votes
0answers
86 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 ...
0
votes
1answer
167 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
160 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%
- ...
0
votes
1answer
438 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); /* ...
0
votes
0answers
550 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 ...
0
votes
0answers
96 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 ...
0
votes
0answers
88 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 ...
0
votes
0answers
550 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 ...