Board index » cppbuilder » error when compliling some code with Borland C++ complier 5.5

error when compliling some code with Borland C++ complier 5.5


2006-12-03 01:05:50 AM
cppbuilder108
hello,
i am trying to compile this code which constantly throws errors in my
face dose anyone have any ideas on how i can get this to work its ment
to Draw a message box that says whats up world
the code is
// PROG3_2.CPP - A simple message box
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
// main entry point for all windows programs
int WINAPI WinMain(HINSTANCE hinstance,
HINSTANCE hprevinstance,
LPSTR lpcmdline,
int ncmdshow)
{
// call message box api
MessageBox(NULL, "What's up world!",
"My First Windows Program",MB_OK);
// exit program
return(0);
} // end WinMain
and i get the error message's i get are
"Borland C++ 5.5.1 for Win32 Copyright <c>1993, 2000 Borland
prog3_2.cpp:
Warning W8057 prog3_2.cpp 19: Parameter 'hinstance' is never used in
function __stdcall WinMain<HINSTANCE__*,HINSTANCE__*,char*,int>
Warning W8057 prog3_2.cpp 19: Parameter 'hprevinstance' is never used
in function __stdcall WinMain<HINSTANCE__*,HINSTANCE__*,CHAR*,INT>
Warning W8057 prog3_2.cpp 19: Parameter 'lpcmdline' is never used in
function __stdcall WinMain<HINSTANCE__*,HINSTANCE__*,char*,int>
Warning W8057 prog3_2.cpp 19: Parameter 'ncmdshow' is never used in
function __stdcall Winmain<HINSTANCE__*,HINSTANCE__*,char*,int>
Turbo Incremental Link 5.00 Copyright <c>1997, 2000 Borland
Error: Unresolved external '_main' referenced from
C:\BORLAND\BCC55\LIB\C0X32.OBJ"
thank you for your help
 
 

Re:error when compliling some code with Borland C++ complier 5.5

I have several issues with what you show:
- You are using the command line tools from C++ Builder, not the old
Borland C++ compiler. Post about those command line tools in a
C++ Builder newsgroup such as
borland.public.cppbuilder.commandlinetools
and not here where people familiar with the product are less likely
to be found.
- Neither of these lines are needed for the program
Quote
#define WIN32_LEAN_AND_MEAN
#include <windowsx.h>
- The warnings are because you declared calling parameters but did not use
them.
In C or C++ programs you can suppress those warnings by putting this on the
line immediately before the function:
#pragma argsused
C++ provides a means to avoid those warnings by not giving names to any
parameter you will not use:
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
- There is an error in the command line you used to build the program but
you did not show the command line so I must guess as to what it was.
Console mode programs start at the function main and GUI programs start at
the function WinMain. Your program has WinMain so is a GUI (Graphical User
Interface) one. The options -WR and -WCR ('/' may be used instead of '-')
build a dynamic linked GUI and Console Mode programs respectively. For
static linked it is -W and -WC. For this program the -WR is appropriate so
the command line would be
bcc32 -WR prog3_2
You can see in this screen capture that what is said above generates no
errors or warnings.
--------------------------------
C:\Documents and Settings\Edward\My Documents\lookat\q195
Quote
type prog3_2.cpp
// PROG3_2.CPP - A simple message box
#include <windows.h>
// main entry point for all windows programs
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
// call message box api
MessageBox(NULL, "What's up world!",
"My First Windows Program",MB_OK);
// exit program
return(0);
} // end WinMain
C:\Documents and Settings\Edward\My Documents\lookat\q195
Quote
bcc32 -WR prog3_2
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
prog3_2.cpp:
Turbo Incremental Link 5.66 Copyright (c) 1997-2002 Borland
C:\Documents and Settings\Edward\My Documents\lookat\q195
Quote

--------------------------------
. Ed
. follow-ups set to borland.public.cppbuilder.commandlinetools
Quote
chris todd wrote in message
news: XXXX@XXXXX.COM ...
hello,

i am trying to compile this code which constantly throws errors in
my face dose anyone have any ideas on how i can get this to work
its ment to Draw a message box that says whats up world

the code is

// PROG3_2.CPP - A simple message box
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>

// main entry point for all windows programs
int WINAPI WinMain(HINSTANCE hinstance,
HINSTANCE hprevinstance,
LPSTR lpcmdline,
int ncmdshow)
{
// call message box api
MessageBox(NULL, "What's up world!",
"My First Windows Program",MB_OK);

// exit program
return(0);
} // end WinMain

and i get the error message's i get are
"Borland C++ 5.5.1 for Win32 Copyright <c>1993, 2000 Borland
prog3_2.cpp:
Warning W8057 prog3_2.cpp 19: Parameter 'hinstance' is never used in
function __stdcall WinMain<HINSTANCE__*,HINSTANCE__*,char*,int>
Warning W8057 prog3_2.cpp 19: Parameter 'hprevinstance' is never used
in function __stdcall WinMain<HINSTANCE__*,HINSTANCE__*,CHAR*,INT>
Warning W8057 prog3_2.cpp 19: Parameter 'lpcmdline' is never used in
function __stdcall WinMain<HINSTANCE__*,HINSTANCE__*,char*,int>
Warning W8057 prog3_2.cpp 19: Parameter 'ncmdshow' is never used in
function __stdcall Winmain<HINSTANCE__*,HINSTANCE__*,char*,int>
Turbo Incremental Link 5.00 Copyright <c>1997, 2000 Borland
Error: Unresolved external '_main' referenced from
C:\BORLAND\BCC55\LIB\C0X32.OBJ"

thank you for your help