You should re-install Visual Studio.
Also,
is wrong. Use int main().Code:void main
{
}
Z.
Printable View
You should re-install Visual Studio.
Also,
is wrong. Use int main().Code:void main
{
}
Z.
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.
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:void main()
{
}
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...Code:int main()
{
return 0;
}
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.
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).
So, according to you people, the safest thing to do is:
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.Code:int main()
{
return 0;
}
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.
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.
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.