Problem in compiling a C code with MSVC++6.00

D

Default User

Babak wrote:

I finally solved the problem with gcc. I used some declared
variables without initialization in my code which seems to make
problems with gcc (but not MSVC).

Probably the MSVC was compiled in Debug mode, and default-initialized
those automatic variables. This is also a major cause of, "it works in
Debug, but blows up real good in Release!!!!"




Brian
 
K

Keith Thompson

Martin Ambuhl said:
Your code as posted has illegal code -- even in C99 and C++ -- because
of your // comments. This is because it gets broken up into
reasonable length lines along the propagation chain. This leaves
stranded parts of your comments as "code" since those parts are no
longer on a line beginning with "//". It is an error to post code
with // comments even in a C++ newsgroup, since they leave
uncompilable crap in their wake.

I think you overstate the case.

Using long // comments in code to be posted to Usenet is a bad idea,
for obvious reasons. Using them in code that will not be posted to
Usenet, and will not otherwise be passed through a filter that will
break long lines (where "long" is defined fairly arbitrarily) should
not be a problem unless there's a concern for portability to C90. For
example I wouldn't hesitate to use // comments if I were writing C++,
and I wouldn't worry too much about keeping them short *unless* I were
going to post the code to Usenet. (I generally try to keep all source
lines down to 80 columns, but that's not always possible.)

You correctly point out the error, but IMHO you overgeneralize it.
Your limited experience does not define C. Declarations intermeshed
with code is almost always poor programming style; comments which
break your program if the line is split is just stupid.

Strictly speaking, ISO/IEC 9899:1999 defines C.

The need to be compatible with C90 is real; apart from that,
interspersing declarations with statements can be useful, particularly
if an initialization depends on a previous statement.

[snip]
 
N

Neil

Martin said:
No, I responded to Neil's bogus points. It is true that Neil was not
the OP of the code, (a certain "Babak", that was). Since Neil
completely associated himself with the errors in that code and asserted
its "correctness" because his Microsoft compiler let him get away with
it, I did not check to see that we were dealing with two idiots rather
than just one. No apology is offered; Neil made it clear that Babak's
errors were also his and he defended them on the basis of his limited
experience.
While // comment code may not translate to the internet It is still
not his problem. I specificly Know MSVC takes // Comments.
Along with Borland C, Keil C, Hi-Tech C, Pardigm C, Metrowork C

If // comment do not work in posting that should be the comment. It was
not the cause of the OPs problem.

Next time I am on MSVC I will check the warning level. The higher the
better (baring the warnings from the MS headers)
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top