Here are my notes on setting up an Emacs C++ development environment. I'm using GNU g++ (4.3.3), GNU make (3.81), GNU gdb (3.8-debian), and GNU emacs (23.0.92.1 built from CVS 2009-04-22) on Ubuntu Linux (9.04 Jaunty Jackalope).
If you don't already have g++, make, and gdb, install them:
sudo apt-get install g++ make gdb
mkdir helloworld
helloworld/hello.cpp:
#include <iostream>
int main(void)
{
char greeting[] = "Hello World!";
std::cout << greeting << std::endl;
return 0;
}
The Perl FAQ has an entry How do I use a regular expression to strip C style comments from a file? Since I've switched to Python, I've adapted the Perl solution to Python. This regular expression was created by Jeffrey Friedl and later modified by Fred Curtis. I'm not certain, but it appears to use the "unrolling the loop" technique described in Chapter 6 of Mastering Regular Expressions.
remove_comments.py:
import re
import sys
def remove_comments(text):
""" remove c-style comments.
text: blob of text with comments (can include newlines)
returns: text with comments removed
"""
pattern = r"""
## --------- COMMENT ...I'm Eliot and this is my notepad for programming topics such as Python, Django, Ubuntu, Emacs, etc... more »