R
Pedro said:Do not add to the list (unless you're considering an "infinite" computer)
void f(void) { ...; f(); }
#define until while
#define the_cows_come_home 17
do {
... stuff ...
} until (the_cows_come_home);
some alternatives (mix and match)
#define hell_freezes_over (1 != 0)
#define no_dog_has_fleas (EOF < 0)
CBFalconer said:#define until while
#define the_cows_come_home 17
do {
... stuff ...
} until (the_cows_come_home);
some alternatives (mix and match)
#define hell_freezes_over (1 != 0)
#define no_dog_has_fleas (EOF < 0)
John F said:Extraordinarily great idea!!! Had a good laugh...
how about:
#define you_are_old_and_grey (0?(0?0:0):1)
#define you_stop_wondering_about_that_constant 1
William J. Leary Jr. said:I put off mentioning this one, because I was SURE someone would beat me to
it.
Maybe someone did and I didn't catch the message.
I've run across this a number of times:
#define ever ;;
for (ever)
{
/* We're in here forever */
}
William J. Leary Jr. said:I put off mentioning this one, because I was SURE someone would beat
me to it. Maybe someone did and I didn't catch the message.
I've run across this a number of times:
#define ever ;;
for (ever)
{
/* We're in here forever */
}
William said:#define ever ;;
for (ever)
{
/* We're in here forever */
}
Guillaume said:Macros can be a great tool, but they should not be used, in my opinion,
as syntactic sugar. The base syntax of the language should not be
modified in any way if you want your code to be readable. A 'for'
loop without two visible ';' is a syntax mess. Don't do it.
Besides, I try to stick to the convention of declaring macros in all
uppercase. This way, you can see immediately if you are dealing with a
macro.
Preprocessors are handy but dangerous, as they are not really part
of the language itself. Thus you should avoid abstracting its use
at all costs.
John F said:#define ever
for (;ever
{
/*code to do*/
}
better?
Keith Thompson said:
If someone reading your code knows C, he knows perfectly well what
"for (;" means; he'll have no idea what "ever" means without looking
it up. If he doesn't know C, no amount of preprocessor trickery will
let him understand the code; rather, it will prevent him from learning
good C.
(I don't think you meant to imply that it *is* better, so take this as
an expansion on what you wrote, not a criticism.)
Note that a sufficiently malicious programmer could do something like
this:
#define ever 0
for (;ever {
/* this is never executed */
}
(I even know people who just wrote for(; and intended to fill the
missing parts later on, but then again forgot to do so some lines later...
For the record, my infinite loop program is still going strong (that's two
days now, I think), but the test so far has been inconclusive.
-snip
Better hope the power doesn't go out!
...
Well, that's what UPS is for. It's uninterruptible, right?
The food might run out. The oceans might dry up. The human race might die
out completely. The sun might bloat out into space and consume the earth in
a fiery death. The combined mass of the entire universe might reach its
expansion limit and then coalesce into the mother of all black holes.
But my UPS will still be supplying power to my PC, because that's what
"uninterruptible" means. And my PC must also somehow survive all this,
because it's running an *infinite* loop.
Richard said:John F said:
For the record, my infinite loop program is still going strong (that's two
days now, I think), but the test so far has been inconclusive.
Richard said:MrG{DRGN} said:
Well, that's what UPS is for. It's uninterruptible, right?
The food might run out. The oceans might dry up. The human race might die
out completely. The sun might bloat out into space and consume the earth in
a fiery death. The combined mass of the entire universe might reach its
expansion limit and then coalesce into the mother of all black holes.
But my UPS will still be supplying power to my PC, because that's what
"uninterruptible" means. And my PC must also somehow survive all this,
because it's running an *infinite* loop.
rami said:
I have written a program for you, that contains an infinite loop, but it
wouldn't be right to show you the code until its test run is complete.
I'd be very interested to see that code too, so... what's the status? Is
it anywhere near infinity yet?
Richard Heathfield said:Man with Oscilloscope said:
137 days later... it's still going strong, but there's some way to go yet.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.