|
CEG 333: Introduction to UnixPrabhaker MatetiEmacs: C++ Mode |
CC Mode is collection of Emacs modes for editing source code in C-related languages, including C++ and Java. It integrates many special features into Emacs for these languages, such as:
M-x global-font-lock-mode)
Emacs will automatically open .cpp files in C++
Mode. The modeline displays the text "C++" to reflect
this.
Some example C++ code (which outputs all its command line arguments, in order) as colorized by Emacs:
#include <cstdio>
int main(int argc, char *argv[]) {
for (int i = 0; i < argc; i++) {
std::printf("arg %i: %s\n", i, argv[i]);
}
return 0;
}
Emacs can also integrate compilation and debugging of programs.
Typing M-x compile can run make,
g++, or any other such command. Emacs will then
automatically parse the output of this command.
If any errors or warnings are encountered during compilation,
Emacs allows the user to view them in the compilation buffer and
automatically jump to problem lines in the original file (using
M-x next-error, M-x previous-error, and
M-x first-error).