Sign in to follow this  
Adel_C

I have problem with "typedef"

Recommended Posts

halleo my frinds, My name is Adel , I am A new member,, My question is: I have written my program by using typedef but I found this error: "LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16" I could not understand this error. My program here: #include<stdio.h> void main() { typedef int integer ; integer a=3; printf("A=%d",a); } thanks my frinds

Share this post


Link to post
Share on other sites
The linker is looking for the entry-point as WinMain. It thinks you're trying to create a Win32 application where what you want to create is a console application. You need to recreate the project as a console application instead of what you chose. Perhaps we could tell you how to do this if you told us which IDE you're using. (I'm assuming a VC++, probably 6)

Share this post


Link to post
Share on other sites
This has nothing to do with the typedef.

Basically, your linker is complaining that it can't find an entry point to your program.

Assuming your compiler can automatically detect wheither you're using main or WinMain, then the only problem is that your main function is listed as "void main()". It must have a return type of int for C++, and even for C it would be better this way (guaranteed to be supported IIRC).

If your compiler still gives you grief using "int main()", you probably selected the wrong type of project. You want a console project, not a windows one.

Share this post


Link to post
Share on other sites
thank you for every body tried help me.
I have solved my problem,I was put Win32 rather than console projedct,but there are aquestion now,

What is the difference between Win32 application and console project and also the others that in the same window (Dynamic-link library,...),,
If there book or refernce help me about that,

I appreciate help,
thank you,
Adel

Share this post


Link to post
Share on other sites
Hi,

welcome to gamedev.net! [smile]

The difference between Win32 and console programs is not great. A console program is automatically a Win32 program, so you can use every Win32 function like MessageBox() in a console program.
The difference is in the startup of the program, you can imagine it like this:

console program starts here


// Your main function
int main( int argc, char* argv[] )
{
// do stuff
return 0; // success code, return another code to signal an error
}

// This WinMain is automatically created and calls your main()
int WinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
{
// open a console (text) window
// redirect output to text window
// parse the command line into argc and argv
// call the main() function
int retcode = main( argc, argv );
// close the console window
return retcode;
}


You can do all these steps by yourself (allocating a console etc), but when you create a program as a console window, the compiler links in some libraries which do it for you automatically and then call main().

Technically, console mode uses a different subsystem than Win32, that means it is linked to different start up libraries.

You find more information about Win32 programming at the Microsoft site. There is also information about character mode applications and DLLs, processes and threads.

Share this post


Link to post
Share on other sites
Please also note there is a For Beginners forum, which is more appropriate for "getting started" questions such as this. It should appear first in the forum list.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this