cygwin 当前版本下的iconv.h有点问题。
那一天编译一个小项目,用到了iconv.h,因为我的源代码是gbk编码的,所以编译参数用到了
-finput-charset=gbk
结果编译就报错如下:
错误:无法从 gbk 转换到 UTF-8
#include <iconv.h>
使用file /usr/include/iconv.h看了一下:
/usr/include/iconv.h: C source, UTF-8 Unicode text
打开/usr/include/iconv.h看了看,可能是中国人写的,其中的注释如
/* Allocates descriptor for code conversion from encoding ‘fromcode’ to
encoding ‘tocode’. */
使用了全角的单引号。
使用命令
iconv -f utf8 -t gbk /usr/include/iconv.h >iconv.h
把utf8转成gbk放到本地,再一次编译,顺利完成。