1

I'm trying to compile c++ code with the following main definition:

int wmain(int argc, wchar_t** argv)

I can compile it correctly with Visual Studio, but g++ fails with the following error messages:

g++ -municode -o l1bCorrector AappL1bCorrector/l1bCorrector.o -L/usr/local/lib -Wl,-Bstatic -lboost_system-mt -lboost_filesystem-mt -lScanexUtilities -Wl,-Bdynamic
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../libcygwin.a(libcmain.o): In function `main':
/usr/src/debug/cygwin-1.7.17-1/winsup/cygwin/lib/libcmain.c:39: undefined reference to `_WinMain@16'
Georg
  • 401
  • 1
  • 5
  • 20
  • Look this: [Can we use wmain() functions with Unix compilers or it'll work only on windows?](http://stackoverflow.com/questions/2438297/can-we-use-wmain-functions-with-unix-compilers-or-itll-work-only-on-windows). – m0nhawk Jan 31 '13 at 08:17

1 Answers1

3

GCC has no support for wmain (even mingw GCC, which I expect to be the best in this respect).

If you need unicode command-line arguments as an array, you can use CommandLineToArgvW on the result of GetCommandLineW.

Anton Kovalenko
  • 20,999
  • 2
  • 37
  • 69
  • Is it possible to use unicode parameters in ANY way without platform-dependent code? – Georg Jan 31 '13 at 08:56
  • 2
    Not when targetting Windows and non-Windows simultaneously. We could just use `mbrtowc` on `argv[..]`, but on Windows, `argv[..]` has already lost some information from the start. – Anton Kovalenko Jan 31 '13 at 09:07
  • @AntonKovalenko, does this mean that I can't use any unicode related functions like `CreateFileW` and etc? –  Jun 24 '16 at 07:10