Horrible Visual C Bug!

S

Serve Laurijssen

Falcon Kirtarania said:
Perhaps not in ISO C, then. Whatever. As long as you don't need to port it
between compilers, it really doesn't matter.

And then comes the time that you have to port it and it needs to be ready
yesterday. It will really make your life easier if you do the portable thing
from the beginning, especially if it doesn't take any extra effort like the
"int main" example. In the end it will make your life easier (and that from
others).
 
T

Thomas Stegen

Falcon said:
It does, as long as you are considering only the standards of those
compilers.

Why this insistance on writing invalid C? Doesn't the
correct version work on your compiler?

It works driving 120mph on a road were the speed limit is
30 mph. Because the police is not out today...
 
R

Rui Maciel

Perhaps not in ISO C, then. Whatever. As long as you don't need to port it
between compilers, it really doesn't matter.


Forgive me for interrupting but correct me if I'm wrong: are you
trying to make up excuses for not complying with the standards?
 
R

Randy Howard

Forgive me for interrupting but correct me if I'm wrong: are you
trying to make up excuses for not complying with the standards?

Looks like it. Getting int main correct is so simple that anyone
refusing to abide by it should be fired anyway.

--
Randy Howard
(remove the obvious bits from my address to reply.)
"Most of the drivers nowadays are a bit like Eddie Irvine, who if
he was half as fast as he thought he was, would be moderate."
-- Sir Stirling Moss
 
R

Randy Howard

It does, as long as you are considering only the standards of those
compilers.

Are you really this clueless, or just a troll? Compilers do not
define or express (recognized) standards by themselves. If you
want to claim "I write in standard Microsoft Visual C/C++ 6.0",
whatever that gibberish might imply, fine. Nobody should hire
you if that's your position however.

The "void main()" silliness got kick-started into heavy incorrect
use BECAUSE of the stupidity of the Microsoft C compiler and its
sample code along time ago. This, followed by some incredibly
bad books on the language by Schildt and his ilk just made it worse.


--
Randy Howard
(remove the obvious bits from my address to reply.)
"Most of the drivers nowadays are a bit like Eddie Irvine, who if
he was half as fast as he thought he was, would be moderate."
-- Sir Stirling Moss
 
F

Falcon Kirtarania

Yes, but since we really don't port main very much, I really don't see the
point. The only reason to do that is if you tend to reuse virtually the
same code and make versions over a long period of time. Which also brings
to a head; what trouble is it to change void to int and say "return 0" at
the end, when it is time to port? I am sure almost everyone would notice if
the void main was the problem.
 
J

Joona I Palaste

Randy Howard <[email protected]> scribbled the following
Are you really this clueless, or just a troll? Compilers do not
define or express (recognized) standards by themselves. If you
want to claim "I write in standard Microsoft Visual C/C++ 6.0",
whatever that gibberish might imply, fine. Nobody should hire
you if that's your position however.
The "void main()" silliness got kick-started into heavy incorrect
use BECAUSE of the stupidity of the Microsoft C compiler and its
sample code along time ago. This, followed by some incredibly
bad books on the language by Schildt and his ilk just made it worse.

Come to think of it, has anyone ever expressed a reason for using void
main() instead of int main()? Whatever reason could there be?
"It works on more compilers." False. It actually works on less.
"You don't have to return a value." You don't have to return a value
from int main() either in some standards, and when you do, you can
safely always return 0.
"It saves typing." Since when does a 4-letter keyword save typing more
than a 3-letter one?
"Microsoft does it." If Microsoft jumped off the Grand Canyon, would
you follow them?
"Following standards is for sissies." Well... =)

--
/-- Joona Palaste ([email protected]) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"And according to Occam's Toothbrush, we only need to optimise the most frequent
instructions."
- Teemu Kerola
 
F

Falcon Kirtarania

But all I am saying is not that it is good syntax, just that it is not
absolutely necessary.
 
J

Joona I Palaste

Falcon Kirtarania <[email protected]> scribbled the following
Yes, but since we really don't port main very much, I really don't see the
point. The only reason to do that is if you tend to reuse virtually the
same code and make versions over a long period of time. Which also brings
to a head; what trouble is it to change void to int and say "return 0" at
the end, when it is time to port? I am sure almost everyone would notice if
the void main was the problem.

If it isn't so much trouble to change void to int and say "return 0",
then why don't you do it? What do you gain by being gratuitously non-
standard? Are you some sort of rebel coder?

--
/-- Joona Palaste ([email protected]) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"And according to Occam's Toothbrush, we only need to optimise the most frequent
instructions."
- Teemu Kerola
 
R

Randy Howard

But all I am saying is not that it is good syntax, just that it is not
absolutely necessary.

Ridiculous. It *IS* absolutely necessary if you don't want to be
taken by a fool. The standard says main ALWAYS returns int. Just
because you happen to have a broken compiler doesn't make it "not
absolutely necessary".
 
J

Jakob Bieling

Falcon Kirtarania said:
Yes, but since we really don't port main very much, I really don't see the
point. The only reason to do that is if you tend to reuse virtually the
same code and make versions over a long period of time. Which also brings
to a head; what trouble is it to change void to int and say "return 0" at
the end, when it is time to port?

You do not have to write 'return 0;' (at least in C++ .. but I assume it
is the same in C). So you see, you actually have to write *less* code to get
correct code! So why do you bother typin 'void', if you could just type
'int'??

Also, the reason 'we don't port main very much' is a poor excuse to
write illegal code, don't you think?
 
C

Christian Bau

"Jakob Bieling said:
You do not have to write 'return 0;' (at least in C++ .. but I assume it
is the same in C). So you see, you actually have to write *less* code to get
correct code! So why do you bother typin 'void', if you could just type
'int'??

Also, the reason 'we don't port main very much' is a poor excuse to
write illegal code, don't you think?

If someone uses "void main" instead of "int main" then you get some idea
of their knowledge, and you can draw your conclusions from that. If they
insist that "void main" is correct then you also get some idea of their
attitude, and you can draw much more important conclusions from that.
 
J

Jakob Bieling

Falcon Kirtarania said:
unless

If you don't need to return an exit code?

Then don't?

int main ()
{
}

Is perfectly valid C and C++ code. No need to return an exit code.
 
O

Oliver Brausch

Hello all,
let me first lose some words to all the nice respons.

For example,
Jakob Bieling said:
'void main' is illegal. It is *always* 'int main'.

Ah yes?! and what does this change to the PROBLEM I described?
I think, you (and other who do this discussion) lose the focus.
No, but your boss could fire you for such C code, since it is invalid.

I would rather fire somebody who always loses the focus instead of such
really nonimportant points. BTW, I always use int main() as you
can see in my programms. But for this example it is absolutely
irrelevant.

Some people claim that the result I wrote is not correct at all.
Of course, it was "return x++" instead and forgot it in the
posting. Another point, that is not important to the problem at all.

You try to change a variable twice, which is invalid, ie. undefined
behaviour. Microsoft's compiler is absolutely right.

Ok, this is correct. I was of the opinion that such statements are
read from left to right. But it seems wrong, even most compilers
would do it like this. Ok, my fault, I learned it now (even
before reading all this flames.)

So thanks for the support.

Oliver
 
J

Jakob Bieling

Oliver Brausch said:
Hello all,
let me first lose some words to all the nice respons.

For example,
"Jakob Bieling" <[email protected]> wrote in message

Ah yes?! and what does this change to the PROBLEM I described?
I think, you (and other who do this discussion) lose the focus.

No, because this might as well have been the source of your problem
after all.
invalid.

I would rather fire somebody who always loses the focus instead of such
really nonimportant points. BTW, I always use int main() as you
can see in my programms. But for this example it is absolutely
irrelevant.

Again: it is not irrelevant. A program using 'void main' may produce any
behaviour.
 
M

Martijn

Ok, this is correct. I was of the opinion that such statements are
read from left to right. But it seems wrong, even most compilers
would do it like this. Ok, my fault, I learned it now (even
before reading all this flames.)

"Would" is the proper word here - first thing I was thinking of that the
optimalization may cause the compiler to things in a different order. I am
not sure why that would be faster...

Martijn
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top