What do I need to do to fix this problem?
Nick
> I am attempting to build a Unicode Win32 GUI application with BC++ 5.02. I
> am using wWinMain instead of WinMain as the program entry point
[snip]
> What do I need to do to fix this problem?
I don't think Borland gives you an equivalent to a /entry option for anything...
I know that previous posts have stated it doesn't give that option for DLLs, so
I doubt it would for the main program. Sounds like you just need to use WinMain
instead of wWinMain...
Nick
Kevin Treybig <kwt...@coes.latech.edu> wrote in message
news:37CF6FD6...@coes.latech.edu...
You are right, Borland C++ 5.x does supply a version of the startup code
(c0w32w.obj) that can be used to link Unicode programs that use wWinMain()
as their entry-point. However, as you've discovered, the IDE provides no
built-in setting to request that it link your program with c0w32w.obj.
So, you have four options, listed here from easiest to not-so-easy (IMO):
1) Firstly, just because the rest of your program might use Unicode
everywhere doesn't mean that you *must* to use wWinMain() as its
entry-point -- you can still use the regular WinMain() (in which case, the
IDE *would* successfully link your program).
Secondly, using WinMain() doesn't prevent your program from receiving
Unicode command-lines, if that's what's important to you about using
wMainMain(). You can *always* retrieve the Unicode-version of your
program's command-line using GetCommandLine().
2) If, on the other hand, you'd like to use wWinMain() as your
entry-point just so that your code can remain compatible with other
environments that support it better than the Borland C++ IDE, you can
simulate it yourself under Borland C++ using GetCommandLine() and the
regular WinMain(), as follows.
#if UNICODE && __BORLANDC__
int PASCAL WinMain(HINSTANCE hNewApp, HINSTANCE, LPSTR, int show)
{
const WCHAR Space[] = L" ";
const WCHAR Quote[] = L"\'";
const WCHAR Null = '\0';
LPWSTR cmd = GetCommandLine();
cmd += wcsspn(cmd, Space);
cmd += wcscspn(cmd + 1, (*cmd == Quote) ? Quote : Space);
if (*cmd != Null) cmd += wcsspn(cmd + 1, Space);
return wWinMain(hNewApp, NULL, cmd, show);
}
#endif
When compiling in other environments, this code will simply disappear and
their "native" wWinMain() will be used. BTW, back in July, I posted
something similar to a previous thread titled "BC++5.02 / UNICODE" in these
forums. See the rest of that posting if you need more details about the
above code.
3) If, for some reason, you've rejected the more "portable" solutions
offer by Options 1 and 2 and still really, really want Borland's actual
c0w32w.obj startup code to call your actual wWinMain(), then you must
*force* the Borland C++ IDE to link with c0w32w.obj instead of its default
c0w32.obj. But, again, unfortunately there is no IDE setting for this --
you have to do it manually.
To do so, start by checking "Show run-time nodes" under
"Options|Environment|Project View". Then, back in the Project window,
delete the special yellow c0w32.obj node. Then, manually insert a new node
named "c0w32w.obj" (which will be the normal blue, but this doesn't
matter). When I performed these steps in a simple test project in Borland
C++ 5.02, I was able to successfully compile, link and run the following
program. With it, I verified that Unicode command-lines were indeed
delivered to wWinMain().
#define UNICODE 1
#include <Windows.h>
int PASCAL wWinMain(HINSTANCE, HINSTANCE, LPWSTR cmd, int)
{
return MessageBox(NULL, cmd, L"Unicode Command-line!", MB_OK);
}
4) Finally, you could always switch to using the command-line tools
instead of the IDE. ;-) There, you can explicitly request that your
program be linked against c0w32w.obj by listing it (instead of c0w32.obj)
on the linker's command-line.
Best regards,
Matt Arnold
Professional Music Products
Mark of the Unicorn, Inc.
http://www.motu.com
In an attempt to foil spammers I use a "fake" e-mail address when posting
to newsgroups. Replace "biteme" with "motu" to obtain my actual address.
*-----------------------------------------------------------------------*
| N O T I C E T O S P A M M E R S |
| |
| Pursuant to US Code, Title 47, Chapter 5, Subchapter II, Sec. 227 any |
| and all unsolicited commercial e-mail sent to this address is subject |
| to a download and archival fee in the amount of US$500.00. E-MAILING |
| THIS ADDRESS DENOTES ACCEPTANCE OF THESE TERMS. For more information |
| go to http://thomas.loc.gov/cgi-bin/bdquery/z?d105:SN01618:@@@D. |
| |
*-----------------------------------------------------------------------*
Nick