|
-
Mar 3rd, 2002, 11:55 PM
#1
You should re-install Visual Studio.
Also,
is wrong. Use int main().
Z.
-
Mar 4th, 2002, 10:08 AM
#2
It's not wrong, but it is bad habit.
The linker error means that it can't find the debug version of the static C runtime library. As Zaei said: re-install VC++.
In the installation, make sure you have these:
Visual C++ -> Options:
C runtime library -> Options:
Static Single-Threaded Libraries
Static Multi-Threaded Libraries
Dynamic Libraries
Not sure about the exact names, but you get the idea.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Mar 4th, 2002, 12:59 PM
#3
Hyperactive Member
OK, I will re-install
Thanks a lot... I'll re-install it soon... I think you're right, maybe I mistakenly unchecked a Visual C++ runtime library.
Another thing I wanted to ask was:
I read somewhere that in C++ this is the way to do it, that you don't have to do:
Code:
int main()
{
return 0;
}
But if you say it is wrong / a bad habit, I guess I will do the second thing. In the other C++'s I thought the first piece of code was 'right,' and I assumed VC++ was the same...
-
Mar 4th, 2002, 02:32 PM
#4
parksie would disagree with you, CornedBee =). I think the logic is that some processors return from a function using the stack, instead of a register, and if you dont return something, things go wacky =(.
Z.
-
Mar 4th, 2002, 06:32 PM
#5
Monday Morning Lunatic
Zaei, funny how you worked out what I'd say 
I checked closer, and the standard appears to be that int main is required, but you don't need a return statement (a compliant compiler will insert return 0, but it can only do that if it's defined to return an int).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Mar 4th, 2002, 06:37 PM
#6
Hyperactive Member
So, according to you people, the safest thing to do is:
Code:
int main()
{
return 0;
}
And that way, processors that can't handle void will be okay, and even if your compiler doesn't add a return 0;, it will be okay since you did.
Correct?
(Whoa! I started this thread because of a linker error and we're in to function return types. And we're discussing it in great detail...)
Zaei you're a psychic... and thanks everyone... (Zaei, CornedBee, and I guess Parksie too, because of Zaei) for helping me.
Last edited by DovyWeiss; Mar 5th, 2002 at 06:40 PM.
-
Mar 5th, 2002, 06:37 AM
#7
As long as you only program for i386 cpus (the ones that are in ususal PCs) you won't have trouble with the void main(), but if you ever program other CPUs (like parksie does, this is the reason why he is so careful) you might get problems if you don't heed the standard.
If the compiler doesn't insert "return 0;" then it will produce an error.
BTW MSVC++ assumes that the function has return type "void" if you don't have a return statement, even if you specified another type.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Mar 5th, 2002, 07:53 PM
#8
Hyperactive Member
As I said before -- thanks, everyone, for all your help. I re-installed VC++ and included the libraries, and all is well...
...except that now I have a new problem with VB (not VC++). I need to know about files I need to distribute with my app...
Please follow this link:
http://www.vbforums.com/showthread.p...hreadid=149387
Thanks a lot: Zaei, CornedBee (fancy new avatar just lately!) and Parksie too.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|