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.

Use the tag for C and Related Modes, which include C, C++, Objective-C, Java, CORBA IDL, Pike and AWK modes.

Emacs also provides basic support of programming through the .

There are separate tags for and as well.

Useful Links:

110 questions
20
votes
1 answer

How to automatically create neat C comment blocks while typing?

Some code editors such as eclipse automatically form neat blocks when you start typing a multi-line comment: Is there some package or another way to do this in emacs too? Edit: To clarify: I do not want a key-combination that inserts a comment…
Geier
  • 692
  • 5
  • 15
12
votes
2 answers

How to get semantic syntax highlighting on emacs for C/C++ code

I'm new to emacs and programming in general so please bear with me. I'm trying to use emacs as my C/C++ IDE, and I noticed that in CC mode the variables/functions seemed to be highlighted only during declaration. My question is Is it possible to…
DJ lee
  • 131
  • 1
  • 4
11
votes
3 answers

How can I automatically insert a prototype in foo.h from foo.c?

Suppose I'm writing a C program in a file foo.c: int add_numbers(int x, int y, int z) { // Very complex implementation here. return x + y + z; } I want a command that will insert a corresponding function prototype in foo.h: int…
Wilfred Hughes
  • 6,890
  • 2
  • 29
  • 59
8
votes
2 answers

Hook that indicates when the cursor has been moved by scrolling

Inspired by this question: Let Emacs move the cursor off-screen, I am considering writing a minor mode that will keep the cursor in a fixed position that is not affected by scrolling operations. I have some ideas of how I might implement this, but…
nispio
  • 8,175
  • 2
  • 35
  • 73
7
votes
2 answers

How to transpose two arguments of a function call for C family languages?

How to swap two arguments for C function calls? eg: my_function(foo, bar, baz); ~~~~~~~~~~~~~^ (cursor location) Should be transposed to the right to make: my_function(bar, foo, baz); The simple case works for this similar question. But fails…
ideasman42
  • 8,375
  • 1
  • 28
  • 105
7
votes
1 answer

How can I build/package Emacs so that the C source files are installed to a standard find-function-C-source-directory?

I want to be able to view C source code of Emacs functions. For example, I want to be able to do M-: (find-function 'message). Emacs prompts me for directory the C sources, so it can set find-function-C-source-directory. However, my distro (Arch…
Wilfred Hughes
  • 6,890
  • 2
  • 29
  • 59
7
votes
3 answers

Better syntax-higlighting for member variables and function calls in cpp-mode

In atom, C++ files are well colored unlike emacs cpp-mode. Emacs does not highlight references to member variables, function calls or member functions. They all are uncolored. The left is from emacs and the other is from atom: See, emacs does not…
Hckr
  • 171
  • 1
  • 4
7
votes
4 answers

How do I disable ffap (find file at point) when the first two non-space characters in a line are '//'?

In Verilog/C/C++, comments can begin with //. Here's an example comment, //This is a comment I like to use the find-file-at-point feature. If my cursor is on the file name in `include "some_file.v". But if my cursor is on the above example…
Kaushal Modi
  • 25,203
  • 3
  • 74
  • 179
6
votes
2 answers

How to compile and run a C++ file?

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't know what does that mean, obviously compiling…
garakchy
  • 193
  • 1
  • 2
  • 9
6
votes
2 answers

How to use C++ comments "//" in c-mode?

In c-mode comment-region is adding /* */ style comments. Is there a way to default to using C++ style // prefix in C source files instead?
ideasman42
  • 8,375
  • 1
  • 28
  • 105
6
votes
2 answers

How to add a new .c file to Emacs source code

I've added my own .c file to Emacs /src directory as well as the following lines emacs.o: ... file.c file.h file.o: file.c in deps.mk I get file.o generated, but it is not linked when generating Emacs executable (at least that's what I see when I…
Sergey
  • 211
  • 1
  • 6
5
votes
2 answers

emacs cscope integration basics

I am a long term eclipse CDT user migrating to emacs (ver. 23.3.1), because I have to work on a large C codebase accessible only through a telnet/ssh shell. After going through several online guides, I have managed to get emacs work with cscope on…
Karko
  • 51
  • 1
  • 2
5
votes
3 answers

Syntax highlight doxygen comments in C/C++? (c-doc-comment-style)

Is it possible to syntax highlight doxygen in C/C++ code? QtCreator and Vim both support basic highlighting so \param, \note... etc are highlighted differently.
ideasman42
  • 8,375
  • 1
  • 28
  • 105
5
votes
1 answer

C/C++ coding in Emacs org-mode's babel

I'm not finding a lot of examples/documentation for the non-REPL world of C/C++ in Emacs org-mode babel. For example, is there a way to break a program up into separate source code blocks, i.e., a block for main, then separate blocks for its func1,…
147pm
  • 2,907
  • 1
  • 18
  • 39
5
votes
1 answer

C brace indentation

I am new to Emacs and trying to learn the basics. I am writing a few C programs and I noticed that the default brace indentation is as follows: for(i = 0; i < 10; ++i) { // code } How would I go about modifying this behaviour to…
Q''
  • 173
  • 7
1
2 3 4 5 6 7 8