This code leads to infinite garbage output on the console:
#include <stdio.h>#include <wchar.h>#include <locale.h>int main(int argc, char **argv) { setlocale(LC_ALL, ""); wprintf(L"%ls\n", L"Hello"); for (int i=0; i<argc; i++) { printf("converted arg %d = %s\n", i, argv[i]); } return (0);}
If to keep just wprintf
or just printf
(in the for
) - everything is OK. Also I tried %S
instead of %ls
in wprintf
, but with the same result. It happens in MinGW as well.
This happens in the last Cygwin (64), Windows 10, gcc version is:
$ LANG= gcc -vUsing built-in specs.COLLECT_GCC=gccCOLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/lto-wrapper.exeTarget: x86_64-pc-cygwinConfigured with: /cygdrive/i/szsz/tmpp/gcc/gcc-9.3.0-1.x86_64/src/gcc-9.3.0/configure --srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-9.3.0-1.x86_64/src/gcc-9.3.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-tsThread model: posixgcc version 9.3.0 (GCC)
$LANG
has correct value... I compile it with gcc -o aaa.exe aaa.c
. What's wrong with the code?