By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,798 Members | 1,766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,798 IT Pros & Developers. It's quick & easy.

Preprocessor

P: n/a
Would you consider this to be destructive to programmers' sanity:

#define main Main
#define cout cerr
#define while(x) if(x)
#define class union
#define true 0
#define false 1

Comments welcome!!!

Dec 26 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a
Protoman wrote:

Comments welcome!!!

I completely have no idea what is that for but if you like
comments here you have mine :-)
#define while(x) if(x)


Here you can not prevent programmer to use expression
which result does not make any sense in term of boolean.

Cheers
--
Mateusz Łoskot
http://mateusz.loskot.net
Dec 27 '05 #2

P: n/a
#define while(x) if(x) means that the preprocessor will substitute
if(x) for any occurance of while(x).

Dec 27 '05 #3

P: n/a
Protoman wrote:
#define while(x) if(x) means that the preprocessor will substitute
if(x) for any occurance of while(x).


What for?
Do you want to do some test cases or what?
Cheers
--
Mateusz Łoskot
http://mateusz.loskot.net
Dec 27 '05 #4

P: n/a
At my work, there's this person who upsets and annoys *everyone*, me,
my bosses, their bosses, the secretaries, absolutely everyone. He's a
grade A psycho. He's also *extremely* arrogant. He keeps trying to get
me and my other coworkers fired; he's even tried once to get my boss
and his boss fired. We're all going to get him with this. Do you know
any other ways of sabotaging his project (BTW, my boss has decided to
cancel the project; he's informed everyone but the man in question, [my
boss plans on firing him later this month] so it doesn't matter; he's
sanctioning this)?

Dec 27 '05 #5

P: n/a

Protoman wrote:
At my work, there's this person who upsets and annoys *everyone*, me,
my bosses, their bosses, the secretaries, absolutely everyone. He's a
grade A psycho. He's also *extremely* arrogant. He keeps trying to get
me and my other coworkers fired; he's even tried once to get my boss
and his boss fired. We're all going to get him with this. Do you know
any other ways of sabotaging his project (BTW, my boss has decided to
cancel the project; he's informed everyone but the man in question, [my
boss plans on firing him later this month] so it doesn't matter; he's
sanctioning this)?

Sounds more like a kindergarden. How old are you kid - 15 or 16?

Dec 27 '05 #6

P: n/a

Protoman wrote in message
<11**********************@g43g2000cwa.googlegroups .com>...
At my work, there's this person who upsets and annoys *everyone*, me,
my bosses, their bosses, the secretaries, absolutely everyone. He's a
grade A psycho. He's also *extremely* arrogant. He keeps trying to get
me and my other coworkers fired; he's even tried once to get my boss
and his boss fired. We're all going to get him with this. Do you know
any other ways of sabotaging his project (BTW, my boss has decided to
cancel the project; he's informed everyone but the man in question, [my
boss plans on firing him later this month] so it doesn't matter; he's
sanctioning this)?


Write a program that will go through his code files and replace all
semi-colons(;) with colons(:). Remove all the 'virtual' from his base class
destructors.

Or, for the best way to 'get' the guy, BE NICE TO HIM!!! Extremely nice!

--
Bob R
POVrookie
Dec 27 '05 #7

P: n/a

BobR wrote:
Write a program that will go through his code files and replace all
semi-colons(;) with colons(:). Remove all the 'virtual' from his base class
destructors.

Or, for the best way to 'get' the guy, BE NICE TO HIM!!! Extremely nice!

--
Bob R
POVrookie


For the first one, how do I do the virtual thing? I know how to do the
semicolon one, #define ; :. As for the second item please define "get".
That makes me uncomfortable. As for the guy, he's even more infuriating
then my PHB.

Dec 27 '05 #8

P: n/a
Protoman wrote:
BobR wrote:
Write a program that will go through his code files and replace all
semi-colons(;) with colons(:). Remove all the 'virtual' from his base class
destructors.

Or, for the best way to 'get' the guy, BE NICE TO HIM!!! Extremely nice!

--
Bob R
POVrookie

For the first one, how do I do the virtual thing? I know how to do the
semicolon one, #define ; :. As for the second item please define "get".
That makes me uncomfortable. As for the guy, he's even more infuriating
then my PHB.


Sounds like you're jealous of him because he actually knows C++. I hope
you're not employed as a C++ guy there if you don't even understand
virtual destructors in abstract base classes.

I hope that your co-worker finds your messages and takes legal action
against you.
Dec 27 '05 #9

P: n/a
puzzlecracker wrote:

Sounds more like a kindergarden. How old are you kid - 15 or 16?


Don't you know? Protoman's a JPL Rocket Scientist(TM), or so he claimed
at one point.
Dec 27 '05 #10

P: n/a

BobR wrote:
Write a program that will go through his code files and replace all
semi-colons(;) with colons(:). Remove all the 'virtual' from his base class
destructors.

Or, for the best way to 'get' the guy, BE NICE TO HIM!!! Extremely nice!

--
Bob R
POVrookie


Please define "get"; you're making me uncomfortable. And I forgot, what
exactly will removing virtuality accomplish? Make his objs destruct
improperly?

Dec 27 '05 #11

P: n/a
Protoman wrote:
At my work, there's this person who upsets and annoys *everyone*, me,
my bosses, their bosses, the secretaries, absolutely everyone. He's a
grade A psycho. He's also *extremely* arrogant. He keeps trying to get
me and my other coworkers fired; he's even tried once to get my boss
and his boss fired. We're all going to get him with this. Do you know
any other ways of sabotaging his project (BTW, my boss has decided to
cancel the project; he's informed everyone but the man in question, [my
boss plans on firing him later this month] so it doesn't matter; he's
sanctioning this)?


No more questions and comments from my side :-)
Cheers
--
Mateusz Łoskot
http://mateusz.loskot.net
Dec 27 '05 #12

P: n/a

"Protoman" <Pr**********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
At my work, there's this person who upsets and annoys *everyone*, me,
my bosses, their bosses, the secretaries, absolutely everyone. He's a
grade A psycho. He's also *extremely* arrogant. He keeps trying to get
me and my other coworkers fired; he's even tried once to get my boss
and his boss fired. We're all going to get him with this. Do you know
any other ways of sabotaging his project (BTW, my boss has decided to
cancel the project; he's informed everyone but the man in question, [my
boss plans on firing him later this month] so it doesn't matter; he's
sanctioning this)?


Fortunately for you that's all a bunch of bull (since, if I recall, you're
still in school). If the above were true, you'd have just provided public
documentation for the lawsuit he'd be sure to file.

Now go troll elsewhere.

Dec 27 '05 #13

P: n/a

Protoman wrote in message
<11**********************@g44g2000cwa.googlegroups .com>...

BobR wrote:
Write a program that will go through his code files and replace all
semi-colons(;) with colons(:). Remove all the 'virtual' from his base class destructors.

Or, for the best way to 'get' the guy, BE NICE TO HIM!!! Extremely nice!

--
Bob R
POVrookie


Please define "get"; you're making me uncomfortable. And I forgot, what
exactly will removing virtuality accomplish? Make his objs destruct
improperly?


The "get" refers to pulling a prank, getting even, etc.

Try the following:

#include <iostream>
class Base1 { public:
~Base1(){ std::cout << "~Base1()\n";}
};

class Derived1 : public Base1 { public:
Derived1(){ std::cout << "Derived1()\n";
array = new char[1024 * 1024];
}
~Derived1(){ std::cout << "~Derived1()\n";
delete [] array;
}
private:
char *array;
};

int main() {
Base1* bp = new Derived1; // Upcast
delete bp;
return 0;
}

Run it, then change:

~Base1(){ std::cout << "~Base1()\n";}
to:
virtual ~Base1(){ std::cout << "~Base1()\n";}

....and run it again. Your findings?

--
Bob R
POVrookie
Dec 27 '05 #14

P: n/a

BobR wrote:
Protoman wrote in message
<11**********************@g44g2000cwa.googlegroups .com>...

BobR wrote:
Write a program that will go through his code files and replace all
semi-colons(;) with colons(:). Remove all the 'virtual' from his base class destructors.

Or, for the best way to 'get' the guy, BE NICE TO HIM!!! Extremely nice!

--
Bob R
POVrookie


Please define "get"; you're making me uncomfortable. And I forgot, what
exactly will removing virtuality accomplish? Make his objs destruct
improperly?


The "get" refers to pulling a prank, getting even, etc.

Try the following:

#include <iostream>
class Base1 { public:
~Base1(){ std::cout << "~Base1()\n";}
};

class Derived1 : public Base1 { public:
Derived1(){ std::cout << "Derived1()\n";
array = new char[1024 * 1024];
}
~Derived1(){ std::cout << "~Derived1()\n";
delete [] array;
}
private:
char *array;
};

int main() {
Base1* bp = new Derived1; // Upcast
delete bp;
return 0;
}

Run it, then change:

~Base1(){ std::cout << "~Base1()\n";}
to:
virtual ~Base1(){ std::cout << "~Base1()\n";}

...and run it again. Your findings?

--
Bob R
POVrookie


Derived's dtor never got called w/o virtuality... excellent... What
about:

#define DEBUG 1
#if DEBUG==1
//all header files and declarations/definitions, etc
#endif

Lets say someone resets debug to 0...

Dec 28 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.