Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell GHC/GCC编译器问题uu STDC_VERSION_uuw/C99来自Stg.h,每个包都失败_Haskell_Gcc_Cabal - Fatal编程技术网

Haskell GHC/GCC编译器问题uu STDC_VERSION_uuw/C99来自Stg.h,每个包都失败

Haskell GHC/GCC编译器问题uu STDC_VERSION_uuw/C99来自Stg.h,每个包都失败,haskell,gcc,cabal,Haskell,Gcc,Cabal,每当我试图在OSX 10.12.6和GCC 4.8.0上安装一个带有cabal(2.0.0)的包时,我都会遇到以下关于GHC 8.2.1中Stg.h文件的错误,这个错误非常神秘。我无法在OSX上安装任何软件包 预期行为: cabal install$packagename应在OSX上安装$packagename,因为cabal和cabal install安装正确 观察到的行为: cabal安装$packagename失败,原因是与名为\uuu STDC\u VERSION\uuu的变量相关的低级

每当我试图在OSX 10.12.6和GCC 4.8.0上安装一个带有cabal(2.0.0)的包时,我都会遇到以下关于GHC 8.2.1中Stg.h文件的错误,这个错误非常神秘。我无法在OSX上安装任何软件包

预期行为:

cabal install$packagename
应在OSX上安装
$packagename
,因为cabal和cabal install安装正确

观察到的行为:

cabal安装$packagename
失败,原因是与名为
\uuu STDC\u VERSION\uuu
的变量相关的低级GHC/GCC问题。我不是一个C程序员,我不希望我正确安装的GHC和cabal无法安装软件包。AFAICT此问题与用户错误无关

Matthew@Mattmac git:the_D*+ ~/Projects/kata/euler>cabal update && cabal 
install optparse-applicative
Downloading the latest package list from hackage.haskell.org
gcc: warning: couldn’t understand kern.osversion ‘16.7.0
gcc: warning: couldn’t understand kern.osversion ‘16.7.0
Warning: --root-cmd is no longer supported, see
https://github.com/haskell/cabal/issues/3353 (if you didn't type --root-cmd,
comment out root-cmd in your ~/.cabal/config file)
Resolving dependencies...
Downloading transformers-compat-0.5.1.4...
Configuring colour-2.3.4...
Configuring transformers-compat-0.5.1.4...
Building colour-2.3.4...
Building transformers-compat-0.5.1.4...
Failed to install transformers-compat-0.5.1.4
Build log ( /Users/Matthew/.cabal/logs/ghc-8.2.1/transformers-compat-0.5.1.4-HHfl4KyHCH71PMx2CRgdve.log ):
cabal: Entering directory '/var/folders/qw/k0t4r5fd5_b0phjvwtxx_n700000gq/T/cabal-tmp-91946/transformers-compat-0.5.1.4'
Configuring transformers-compat-0.5.1.4...
gcc: warning: couldn’t understand kern.osversion ‘16.7.0
Preprocessing library for transformers-compat-0.5.1.4..
Building library for transformers-compat-0.5.1.4..
[1 of 2] Compiling Control.Monad.Trans.Instances ( src/Control/Monad/Trans/Instances.hs, dist/build/Control/Monad/Trans/Instances.o )
[2 of 2] Compiling Paths_transformers_compat ( dist/build/autogen/Paths_transformers_compat.hs, dist/build/Paths_transformers_compat.o )
[1 of 2] Compiling Control.Monad.Trans.Instances ( src/Control/Monad/Trans/Instances.hs, dist/build/Control/Monad/Trans/Instances.p_o )
In file included from /Library/Frameworks/GHC.framework/Versions/8.2.1-x86_64/usr/lib/ghc-8.2.1/include/Rts.h:30:0: error:
    0,
                     from /var/folders/qw/k0t4r5fd5_b0phjvwtxx_n700000gq/T/ghc92089_0/ghc_7.c:2:

/Library/Frameworks/GHC.framework/Versions/8.2.1-x86_64/usr/lib/ghc-8.2.1/include/Stg.h:30:3: error:
     error: #error __STDC_VERSION__ does not advertise C99 or later
     # error __STDC_VERSION__ does not advertise C99 or later
       ^
   |
30 | # error __STDC_VERSION__ does not advertise C99 or later
   |   ^
`gcc' failed in phase `C Compiler'. (Exit code: 1)
cabal: Leaving directory '/var/folders/qw/k0t4r5fd5_b0phjvwtxx_n700000gq/T/cabal-tmp-91946/transformers-compat-0.5.1.4'
Failed to install colour-2.3.4
Build log ( /Users/Matthew/.cabal/logs/ghc-8.2.1/colour-2.3.4-9c0ktEQZfar3Wigr5kT6BU.log ):
cabal: Entering directory '/var/folders/qw/k0t4r5fd5_b0phjvwtxx_n700000gq/T/cabal-tmp-91945/colour-2.3.4'
Configuring colour-2.3.4...
Preprocessing library for colour-2.3.4..
Building library for colour-2.3.4..
[ 1 of 14] Compiling Data.Colour.CIE.Chromaticity ( 
Data/Colour/CIE/Chromaticity.hs, dist/build/Data/Colour/CIE/Chromaticity.o )
...
[ 1 of 14] Compiling Data.Colour.CIE.Chromaticity ( Data/Colour/CIE/Chromaticity.hs, dist/build/Data/Colour/CIE/Chromaticity.p_o )

In file included from /Library/Frameworks/GHC.framework/Versions/8.2.1-x86_64/usr/lib/ghc-8.2.1/include/Rts.h:30:0: error:
    0,
                     from /var/folders/qw/k0t4r5fd5_b0phjvwtxx_n700000gq/T/ghc92201_0/ghc_3.c:2:

/Library/Frameworks/GHC.framework/Versions/8.2.1-x86_64/usr/lib/ghc-8.2.1/include/Stg.h:30:3: error:
     error: #error __STDC_VERSION__ does not advertise C99 or later
     # error __STDC_VERSION__ does not advertise C99 or later
       ^
   |
30 | # error __STDC_VERSION__ does not advertise C99 or later
   |   ^
`gcc' failed in phase `C Compiler'. (Exit code: 1)
cabal: Leaving directory '/var/folders/qw/k0t4r5fd5_b0phjvwtxx_n700000gq/T/cabal-tmp-91945/colour-2.3.4'
cabal: Error: some packages failed to install:
ansi-terminal-0.7.1.1-3eOIKoB8mo97DkHMJ6AgBw depends on ansi-terminal-0.7.1.1
which failed to install.
ansi-wl-pprint-0.6.8.1-Ctcte9oFd5tFGoIV7u576g depends on
ansi-wl-pprint-0.6.8.1 which failed to install.
colour-2.3.4-9c0ktEQZfar3Wigr5kT6BU failed during the building phase. The
exception was:
ExitFailure 1
optparse-applicative-0.14.0.0-Iaq7kOKFg2Z4XsKvk269H6 depends on
optparse-applicative-0.14.0.0 which failed to install.
transformers-compat-0.5.1.4-HHfl4KyHCH71PMx2CRgdve failed during the building phase. The exception was:
ExitFailure 1
这个错误令人难以置信地神秘

事实上,这看起来很清楚:

error: #error __STDC_VERSION__ does not advertise C99 or later
C头文件
Stg.h
正在检查编译器是否支持C99(标准ISO C的1999版本),使用标准宏
\uuuuuuu STDC\uuuuuu
。由于没有相应地设置,编译器不符合C99,C源代码会触发错误

基本上,
Stg.h
拒绝使用甚至不支持已有18年历史的C标准的C编译器进行编译。很合理

GCC4.8看起来确实很古老:最新的GCC4.1。如果不是最新的,我会尝试将GCC升级到更新的版本



更新:正如基思·汤普森(Keith Thompson)在下面指出的那样,GCC 4.8尽管已经过时,但如果通过标志
-std=C99
,它仍然可以支持C99。应该有办法指示
cabal
将此标志传递给
gcc
,但我不记得如何传递。为此,应该有一些名为
cflags
的选项。

由于该错误与Haskell或安装无关,我认为该错误与已安装的系统无关。GCC 4.2/4.8通常用于企业系统,Haskell系统文档中未提及版本要求(很少提及GHC较旧版本的ghci单机版,以及较新版本的LLVM单机版)<代码>brew升级gcc和别名gcc解决了该问题。谢谢@chiIt不需要升级gcc。gcc 4.8.0于2013年发布。默认情况下,它不支持C99。您只需要使用
-std=c99
(支持c99)或
-std=gnu99
(支持带有GNU扩展的c99)调用它。默认语言版本为
-std=gnu89
。对于较新版本,默认值为
-std=gnu11
。(但如果你已经升级了gcc,也应该可以解决它。)@KeithThompson啊,对了。这是一个很好的建议。我不记得如何说服阴谋集团传递这面旗帜,但这应该是可行的。这令人难以置信地沮丧。我们不得不修改GHC包含文件来删除它们,因为已经过了好几个月了,现在还没有修复。。。