Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Tor Lillqvist <tml-X3B1VOXEql0 <at> public.gmane.org>
Subject: Re: link error when using _tmain
Newsgroups: gmane.comp.gnu.mingw.user
Date: Saturday 23rd June 2007 11:02:30 UTC (over 10 years ago)
Dave Murphy writes:
 > I'm trying to write some code which will deal with unicode
 > filenames

 > #define _UNICODE
 > #define _WIN32_WINNT 0x0501

 > #include 

 > int _tmain(int argc, TCHAR *argv[]) {

No need to use that _UNICODE, , _tmain and TCHAR stuff just
because you want to handle Unicode filenames. (Especially not if you
come from a Unix background and find it weird. It just makes Windows
programming seem more obscure than it actually is.)

Also, as you notice, the #define _UNICODE and then _tmain(int,TCHAR**)
approach apparently isn't implemented on mingw.

Just write a normal C program with main(int argc, char **argv), and
then for full Unicode file names use wchar_t strings and the wide char
versions of the Win32 API explicitly.

If you want to be able to accept full Unicode command-line arguments,
I suggest you fetch the wide character command line separately with
GetCommandLineW() and split it into a wide character string array with
CommandLineToArgvW().

 > #include 

Just spell it  like everybody else.

 > The link error is
 > 
 > /mingw/lib/libmingw32.a(main.o):main.c:(.text+0x106): undefined 
 > reference to [email protected]'

If you look in mingw's  you see:

#if 0  /* no  wide startup module */
#define _tmain      wmain
#define _tWinMain   wWinMain
#define _tenviron   _wenviron
#define __targv     __wargv
#endif

I.e. mingw doesn't implement a wide character startup module, so using
a wmain() (which _tmain is supposed map to when _UNICODE is defined)
won't work.

 > Is there a simpler way to do this and avoid the win32 specific
 > code? I'm intending to work with UTF8 on linux & OSX and convert
 > that into the VFAT UTF16 format.

If you can accept a 3rd-party LGPL library dependency, GLib contains
directory reading functions and uses UTF-8 for file names on
Windows. See
http://developer.gnome.org/doc/API/2.0/glib/glib-File-Utilities.html#GDir

--tml

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
MinGW-users mailing list
[email protected]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
 
CD: 4ms