startup function

Started by
29 comments, last by Falken42 17 years, 11 months ago
Quote:Original post by Evil Steve
Remove /NODEFAULTLIB ?


When I do that I get

--------------------Configuration: Test - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Test.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Test.exe - 2 error(s), 0 warning(s)
Advertisement
Just save yourself the effort and put

#define MyNewMainFunctionLOL main

at the top of your file or something. Seriously. There's no good reason to be bothering with stuff like this, unless you really know what you're doing. And people who generally know what they're doing don't ask how to do things they already know how to do. Or something.
Why do you need to call something before main, exactly?
Wouldn't this have the same effect?

void foo(){}int main(){    foo()//Other stuff    return 0;}



It seems like you're trying to do very complicated things without knowing or being able to explain why you need to do them in the first place.

I'll also hop on the 'Use VC2005' bandwagon. VC6 is about 10 years old and is pre-standards.
You could try putting in a dummy main() function. If you tell the linker to use your own entry point, then it should ignore it - although I don't know.

You'll ahve to read those links LessBread linked - that explains all the stuff you need to do if you change the entry point.

Why are you doing this anyway? What's wrong with Mushu's suggestion?
Can you explain us what you're trying to do and maybe we'll be able to give you more explanations on how to achieve it?
Quote:Original post by xEricx
Can you explain us what you're trying to do and maybe we'll be able to give you more explanations on how to achieve it?


I came to know that we can do such thing and that is why I wanted to know "How to do that"

I know I am not good at C/C++ but you guy's don't have to say that again an again.

Curiousity is a good thing. I don't think anyone has unfairly said anything about your programming skills.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Quote:Original post by Mushu
Quote:Original post by TEUTON
Quote:Original post by JohnBSmall
No. You don't want to do that.

???

Every time you compile something in VC6, God kills a kitten.

Please, think of the kittens. (download VC2005)


So far I've killed over 1,500 kittens... (and counting ;) ) I've actually wondered if you could skip the main functions, thanks guys!
We should do this the Microsoft way: "WAHOOOO!!! IT COMPILES! SHIP IT!"
Quote:Original post by Evil Steve
Remove /NODEFAULTLIB ?


crt0 (which contains the real entry point) calls main(). So you have to specify that you don't want this startup code - hence the /NODEFAULTLIB.

A good alternative is to build your own printf() [smile]

But in the meantime, I don't see what's the purpose of this. This is used in farily rare cases (mostly embedded software) and has little use in real life.

Regards,
The only cases I have seen this sort of stuff used is OS development (where the stuff needed to run the MS init code doesn't exist), language development (where it doesn't apply even if it does exist), and those relatively pointless "squeeze every last byte out this executable" contests.

Embedded software could concievably be considered a special case of #1 or #2.
-Mike

This topic is closed to new replies.

Advertisement