This found in some code
#define sizeof(x) 128
#include ...
#undef sizeof
#undef sizeof
I'm glad they undef'd that twice, just to make sure it didn't get stuck
This found in some code
#define sizeof(x) 128
#include ...
#undef sizeof
#undef sizeof
I'm glad they undef'd that twice, just to make sure it didn't get stuck
You don't suppose for a moment it's documented why it's necessary to output 5 extra spaces? (it might be 6, it's a little hard to tell). All I can tell is that it's the first line in the output file.
I think it's processed by another program. And if that program is actually dependent on the number of characters in the first line, god help us.
There's a lot of this in the code as well:
string out; out.clear(); out.append("abcde ", 6); out.append(another c string); out.append(c++ string); outfile << out;
Obviously, someone has decided the ?: operator reduces the clarity of their code.
string::size_type loc = inFileName_.find("Info",0); if (loc != string::npos) { outFile << "XXX " << xxxName_ << " \n"; } else { outFile << "XXX " << xxxName_ << " \n"; }
@Zecc said:
Where exactly is
culprit1_has_data
initialized?
There's a static initialiser I left out. It's C++ so there has to be one. And the class wasn't really called Base. It was slightly more meaningful.
Code review = 'does it work? OK then'. Some code reviews don't involve even that...
@toth said:
Do I detect global variables? Dear God, tell me those classes aren't modifying global variables.
They're public static class members. So definitely not global variables. Perish the thought.
Firstish post, so I expect you'll be cruel.
Anyway, I was looking at part of our codebase and I found this (C++)
typedef std::vector<int> DATA; class Base { public: Base() {}; virtual ~Base() {}; virtual void FillIn_Data() = 0; }; class Culprit1_Data : public Base { public: Culprit1_Data() {}; virtual ~Culprit1_Data() {}; void FillIn_Data() { culprit1_data.push_back(VALUE1); //repeat for several different values culprit1_has_data = true; } static DATA culprit1_data; static bool culprit1_has_data; }; //omitted class Culprit2 with members culprit2_data and culprit2_has_data and a different list of values to push back. //omitted swathes of other code class Culprit1 : public Other_Class { .... void set_Culprit1(int thing) { if (!Culprit1_Data::culprit1_has_data) { Base *pCulprit1_Data = 0; pCulprit1_Data = new Culprit1_Data; pCulprit1_Data->FillIn_Data(); delete pCulprit1_Data; } bool found = false; if (Culprit1_Data::culprit1_has_data){ DATA::iterator p; for (p = Culprit1_Data::culprit1_data.begin(); p != Culprit1_Data::culprit1_data.end(); p++) { if (*p -- thing) { found = true; break; } } if (found) data_ = thing else throw invalid_param_exception(); } //some other stuff of no interest private: int data_; }
and yes. There's a Class2 which is almost indistinguishable from Class1, apart from the using Culprit2 instead of Culprit1.
Apparently defining an array of ints was too inflexible, or not OO enough or something.
PS - feel free to re-indent it - it was indented when I got it, but as I said, this is my first post.
Done. Removed the code tags, replaced them with pre's. Thank you for not using the code BB-code, thank you for having indentation already. --Ling