prinx
asked on
Error: Unresolved external '_main' referenced from C:\BORLAND\C++\LIB\C0X32.OBJ
i tried to compile the code below :
#include <windows.h>
LRESULT WINAPI MainWndProc( HWND, UINT, WPARAM, LPARAM );
HANDLE ghInstance;
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow )
{
WNDCLASS wc;
MSG msg;
HWND hWnd;
if( !hPrevInstance ) {
wc.lpszClassName = "GenericAppClass";
wc.lpfnWndProc = MainWndProc;
wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = (HBRUSH)( COLOR_WINDOW+1 );
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0; RegisterClass( &wc );
}
ghInstance = hInstance;
hWnd = CreateWindow( "GenericAppClass", "Generic Application", WS_OVERLAPPEDWINDOW|WS_HSC ROLL|WS_VS CROLL, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL );
ShowWindow( hWnd, nCmdShow );
while( GetMessage( &msg, NULL, 0, 0 ) ) {
TranslateMessage( &msg ); DispatchMessage( &msg );
}
return msg.wParam;
}
LRESULT CALLBACK MainWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg ) {
case WM_DESTROY: PostQuitMessage( 0 ); break;
default: return( DefWindowProc( hWnd, msg, wParam, lParam ));
}
return 0;
}
and it generates an error on my borland c++ compiler
"
Error: Unresolved external '_main' referenced from C:\BORLAND\C++\LIB\C0X32.O BJ"
is this something wrong wif the compiler or the code ?
and another thing is..can someone explain to me y "
ghInstance = hInstance;" is declared ?
i was referin to this example "http://msdn.microsoft.com/library/psdk/buildapp/generic_8038.htm" when i did the code above
thanx alot
#include <windows.h>
LRESULT WINAPI MainWndProc( HWND, UINT, WPARAM, LPARAM );
HANDLE ghInstance;
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow )
{
WNDCLASS wc;
MSG msg;
HWND hWnd;
if( !hPrevInstance ) {
wc.lpszClassName = "GenericAppClass";
wc.lpfnWndProc = MainWndProc;
wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = (HBRUSH)( COLOR_WINDOW+1 );
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0; RegisterClass( &wc );
}
ghInstance = hInstance;
hWnd = CreateWindow( "GenericAppClass", "Generic Application", WS_OVERLAPPEDWINDOW|WS_HSC
ShowWindow( hWnd, nCmdShow );
while( GetMessage( &msg, NULL, 0, 0 ) ) {
TranslateMessage( &msg ); DispatchMessage( &msg );
}
return msg.wParam;
}
LRESULT CALLBACK MainWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg ) {
case WM_DESTROY: PostQuitMessage( 0 ); break;
default: return( DefWindowProc( hWnd, msg, wParam, lParam ));
}
return 0;
}
and it generates an error on my borland c++ compiler
"
Error: Unresolved external '_main' referenced from C:\BORLAND\C++\LIB\C0X32.O
is this something wrong wif the compiler or the code ?
and another thing is..can someone explain to me y "
ghInstance = hInstance;" is declared ?
i was referin to this example "http://msdn.microsoft.com/library/psdk/buildapp/generic_8038.htm" when i did the code above
thanx alot
Check you preprocess definition in compiler. I think you have it wrong. How did you created your project?
You probably running console application. So you need:
1. create new win32 project (not console)
OR
2. change the compiler instruction:
entry point (/ENTRY) to WinMainCRTStartup
subsystem (/SUBSYSTEM) to winmain
check MSDN for mor detail
--EC--
1. create new win32 project (not console)
OR
2. change the compiler instruction:
entry point (/ENTRY) to WinMainCRTStartup
subsystem (/SUBSYSTEM) to winmain
check MSDN for mor detail
--EC--
ASKER
hmmm..i jus found out to use -tW at the comand line to create windows app
so e 1st error msg prob is solved.
and another thing is..can someone explain to me y "
ghInstance = hInstance;" is declared ?
i was referin to this example "http://msdn.microsoft.com/library/psdk/buildapp/generic_8038.htm" when i did the code above
so e 1st error msg prob is solved.
and another thing is..can someone explain to me y "
ghInstance = hInstance;" is declared ?
i was referin to this example "http://msdn.microsoft.com/library/psdk/buildapp/generic_8038.htm" when i did the code above
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
...what nietod said.
As per custom, when a variable is prefixed with a lower case 'g', the intent is to inform the reader that the variable is in the global scope.
As per custom, when a variable is prefixed with a lower case 'g', the intent is to inform the reader that the variable is in the global scope.
Strange question :(
I think it was elcaptian that really answered the question.