我首先在VS2010中使用Microsoft VC启动了C.我最近找到了一些工作,但我一直在使用RHEL 5和GCC.我的代码主要是原生C,但我注意到一件事……
GCC似乎没有认识到<元组>头文件或元组模板.起初我想也许这只是一个错字,直到我查看cplusplus.com并发现标题确实不是标准库的一部分.
问题是我喜欢在Visual Studio中编写我的代码,因为环境比eclipse或netbeans更优越,更美观,调试也很简单.问题是,我已经编写了很多代码来使用元组,我真的很喜欢我的代码.我该怎么处理这个问题?
这是我的代码:
using std::cout; using std::make_tuple; using std::remove; using std::string; using std::stringstream; using std::tolower; using std::tuple; using std::vector; // Define three conditions to code enum {DONE,OK,EMPTY_LINE}; // Tuple containing a condition and a string vector typedef tuple<int,vector<string>> Code; // Passed an alias to a string // Parses the line passed to it Code ReadAndParse(string& line) { /***********************************************/ /****************REMOVE COMMENTS****************/ /***********************************************/ // Sentinel to flag down position of first // semicolon and the index position itself bool found = false; size_t semicolonIndex = -1; // Convert the line to lowercase for(int i = 0; i < line.length(); i++) { line[i] = tolower(line[i]); // Find first semicolon if(line[i] == ';' && !found) { semicolonIndex = i; // Throw the flag found = true; } } // Erase anything to and from semicolon to ignore comments if(found != false) line.erase(semicolonIndex); /***********************************************/ /*****TEST AND SEE IF THERE'S ANYTHING LEFT*****/ /***********************************************/ // To snatch and store words Code code; string token; stringstream ss(line); vector<string> words; // A flag do indicate if we have anything bool emptyLine = true; // While the string stream is passing anything while(ss >> token) { // If we hit this point,we did find a word emptyLine = false; // Push it onto the words vector words.push_back(token); } // If all we got was nothing,it's an empty line if(emptyLine) { code = make_tuple(EMPTY_LINE,words); return code; } // At this point it should be fine code = make_tuple(OK,words); return code; }
反正有没有从编译器不兼容性中保存我的代码?