On 18 Sep 2003 15:28:48 -0700,
pr*******@hotmail.com (Ken Innes) wrote:
Gustav Svensson <gu***@matris.org> wrote in message news:<20030917234735.7301d4bf.gu***@matris.org>... You dont need any of that windows-api stuff, just write a normal main function:
int main()
{
printf("Hello world!!\n");
return 0;
}
and you should get a command line program.
But I do need that windows-api stuff, because I want the program to
run as a Windows program with a Window-interface as well as on a
command line without a Window-interface.
Originally, I was hoping that I could just put a main() function in
there and that when run from the command line the program would
automatically call it instead of WinMain(), but that doesn't seem to
be the case.
First, see Kevin Goodsell's message about topicality, and please
follow that advice.
Now, a standard C++ program (for a hosted implementation) _must_ have a
'main' function. Otherwise it isn't standard. Some compilers, among
them Windows compilers, allow e.g. 'WinMain' as a non-standard
extension to the language, but note well: all compilers I'm aware of
also support standard 'main' for any kind of program.
One solution to the apparent problem is to create two different
programs, of different kinds, where e.g. one uses the other. <ot>It would
be a good idea to rename the Windows console one to [.com]; that little
trick, which has to do with the Windows command interpreter's search for
programs, was used by e.g. MS Developer Studio 6.0.</ot>