Bug记录 · 2022年11月25日

cannot open `(x86)GnuWin32/share/bison/m4sugar/m4sugar.m4′: No such file or directory 使用Bison报错

我的Bison默认路径都是是C:\Program Files (x86)\GnuWin32
版本是2.4.1,从这里下载的:http://downloads.sourceforge.net/gnuwin32/bison-2.4.1-setup.exe

注意!!问题来了!由于这个版本的Bison有bug,但后来没有更新的Windows上的Bison版本,所以这个古老的问题一直留着,会导致"Program Files (x86)"路径中间的空格被分开!!!
我看了一个叫做Julien Blitte的人写的文章,我十分感谢他,十分尊敬和崇拜他,他解答了我的疑惑,文章为:http://marin.jb.free.fr/bison/
这篇文章里他说:This version suffer of a bug due to a limitation of a lazy Microsoft implementation of the function _spawnvp() which does not support spaces argument.

就是说,这个路径中间有文件名,在传参的时候被当成了空格分开的多个字符串,于是安装是没问题,但使用的时候会报错:

m4: cannot open Files’: No such file or directory
m4: cannot open(x86)GnuWin32/share/bison’: No such file or directory
m4: cannot open C:\Program’: No such file or directory
m4: cannot openFiles’: No such file or directory
m4: cannot open `(x86)GnuWin32/share/bison/m4sugar/m4sugar.m4′: No such file or directory
解决方法要么不要用默认的路径安装(例如用C:\bison,路径中不要有空格),要么直接用这个大佬修改Bison源码后重新编译的版本,大佬的链接网页拉到最下面有下载,直接替换安装后的那个C:\Program Files (x86)\GnuWin32…..省略号里面的那个bison.exe
这个问题只要是我这个版本的Bison原版安装的必有这个问题,现在没问题一会用的时候也有问题。