https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108865
Bug ID: 108865
Summary: gcc on Windows fails with Unicode path to source file
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: driver
Assignee: unassigned at gcc dot gnu.org
Reporter: costas.argyris at gmail dot com
Target Milestone: ---
>From Windows Command Prompt, temp has a subfolder named ﹏
(https://www.compart.com/en/unicode/U+FE4F) with a source file in it. Try to
compile it:
C:\Users\cargyris\temp>gcc ﹏\src.c
gcc: error: ?\src.c: Invalid argument
gcc: fatal error: no input files
compilation terminated.
Note how ﹏ was destroyed into ?
The problem starts all the way from gcc's main function at gcc-main.cc
The main function is the normal one which takes char *argv[], that is, it takes
its command-line arguments as char-based strings. On Windows, this means
that the arguments will be interpreted using the local Windows ANSI codepage,
and, as a result, the ﹏ character gets destroyed right from the start - gcc
never sees it correctly.
The way to see the Unicode args properly would be to use wmain instead of main,
which takes wchar_t *argv[] and uses UTF-16.
Would it ever be considered to change main to wmain when compiling for Windows
+ mingw-w64 in order to achieve support for Unicode paths on Windows?
There is also another solution outside of gcc: Changing the ANSI code page
to UTF-8. This can be done either on a global system level (for the whole
Windows OS) or on a per-process level, specifically targeting gcc to use UTF-8
as it's ANSI code page. These approaches require user intervention though,
whereas if the Unicode main was used (wmain) things would just work with
Unicode paths without the user having to do anything special.