I am insane, but I didn't say a full-blown IDE. Just an interpreter. Read from stdin, write to stdout. For example:
#include <string>
#include <sys/types.h>
#include <unistd.h>
#include <fstream>
#include <vector>
#include <iostream>
using namespace std;
ostream& operator<<(ostream& ostr, vector<string> in) {
ostr << "[\"";
for(vector<string>::iterator it = in.begin(); it != in.end(); it++) {
ostr << *it << '"';
if(it+1 != in.end()) ostr << ",\"";
}
ostr << ']' << endl;
return ostr;
}
vector<string> eval(vector<string> what) {
ofstream out("temp.cpp", ios_base::trunc);
vector<string> ret;
if(!out.is_open()) throw "File creation failure";
out << "#include \"includes.h\"" << endl;
out << "int main(int argc, char** argv) {" << endl;
out << "setup();" << endl;
for(vector<string>::iterator it = what.begin(); it != what.end(); it++)
out << *it << endl;
out << "teardown();" << endl;
out << "return 0;" << endl;
out << "}" << endl;
out.close();
pid_t f_id = vfork();
if(f_id < 0) throw "Fork failure";
else if(f_id == 0) {
pid_t f_id2 = vfork();
if(f_id2 < 0) throw "Fork failure";
else if(f_id2 == 0)
execlp("g++", "g++", "-o", "temp", "temp.cpp", NULL);
else
execlp("./temp", "./temp", NULL);
}
else {
ifstream in("temp.out");
string line;
while(getline(in, line)) ret.push_back(line);
}
return ret;
}
int main() {
string input;
vector<string> vin;
while(cin.good()) {
getline(cin, input);
vin.push_back(input);
}
cout << eval(vin) << endl;
return 0;
}
That, along with the other file, includes.h, will work similarly to an interpreter.
#include <algorithm>
#include <complex>
#include <exception>
#include <list>
#include <stack>
#include <bitset>
#include <csetjmp>
#include <fstream>
#include <locale>
#include <stdexcept>
#include <cassert>
#include <csignal>
#include <functional>
#include <map>
#include <cctype>
#include <cstdarg>
#include <iomanip>
#include <memory>
#include <streambuf>
#include <cerrno>
#include <cstddef>
#include <ios>
#include <new>
#include <string>
#include <cfloat>
#include <cstdio>
#include <iosfwd>
#include <numeric>
#include <typeinfo>
#include <ciso646>
#include <cstdlib>
#include <iostream>
#include <utility>
#include <climits>
#include <cstring>
#include <queue>
#include <valarray>
#include <clocale>
#include <ctime>
#include <iterator>
#include <set>
#include <vector>
#include <cmath>
#include <deque>
#include <limits>
#include <sstream>
using namespace std;
streambuf *backup, *outbuf;
ofstream out("temp.out");
void setup() {
outbuf = out.rdbuf();
backup = cout.rdbuf(outbuf);
}
void teardown() {
cout.rdbuf(backup);
out.close();
}
That long list of #include's is every header file in the C++ Standard Library. Other common third-party libraries such as the POSIX library or Boost were not included for sanity purposes.
EDIT: Indentation formatting was bugging me. I think I program in Python too much.