473,473 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Preprocessor

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
14 2238
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
#define while(x) if(x) means that the preprocessor will substitute
if(x) for any occurance of while(x).

Dec 27 '05 #3
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
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

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

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

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
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
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

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
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

"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

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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

205
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
24
by: Nudge | last post by:
I have an array, and an unrolled loop which looks like this: do_something(A); do_something(A); .... do_something(A); I thought: why should I type so much? I should write a macro. So I was...
16
by: Trying_Harder | last post by:
Is it possible to redefine a macro with global scope after undefining it in a function? If yes, could someone explain how? /If/ my question above isn't very clear you can refer to the...
13
by: seemanta dutta | last post by:
Greetings C gurus, I have used preprocessor directives since a very long time. But whenever I see some professional piece of C code, the linux kernel for example, I get literally confused by the...
18
by: /* frank */ | last post by:
My teacher said that array in C is managed by preprocessor. Preprocesser replace all array occurences (i.e. int a ) with something that I don't understand/remember well. What's exactly happens...
13
by: Chris Croughton | last post by:
Is the following code standard-compliant, and if so what should it do? And where in the standard defines the behaviour? #include <stdio.h> #define DEF defined XXX int main(void) { int...
9
by: Walter Roberson | last post by:
I have run into a peculiarity with SGI's C compiler (7.3.1.2m). I have been reading carefully over the ANSI X3.159-1989 specification, but I cannot seem to find a justification for the behaviour....
2
by: Paolo | last post by:
I imported a VC++6.0 project into VC++7.1. The conversion operation makes a mess with Preprocessor Definitions, adding a "$(NoInherit)" for each file. For example: I had a DLL project in VC++6.0...
32
by: spibou | last post by:
Is the output of the C preprocessor deterministic ? What I mean by that is , given 2 compilers which conform to the same standard, will their preprocessors produce identical output given as input...
31
by: Sam of California | last post by:
Is it accurate to say that "the preprocessor is just a pass in the parsing of the source file"? I responded to that comment by saying that the preprocessor is not just a pass. It processes...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.