我的Haskell包(包括C++)在Mac上的Github操作失败-如何在Mac上启用C++11?

lskq00tm  于 8个月前  发布在  Mac
关注(0)|答案(1)|浏览(75)

我在Github上为我的'numerical-integration'库做了一些动作。除了Mac上的那些,它们都工作得很好。在Mac的警告和错误消息中,有:

    • 注意:扩展自宏'_LIBCPP_DEPRECATED_CXX03_FUNCTION'属性((已弃用(“不再支持在C03中使用std::function。请升级到C11或更高版本,或使用其他类型”))*
    • 警告:'function<double(double)>'已弃用:在C03中不再支持std::function。请升级到C11或更高版本,或使用不同的类型[-Wdeprecated-declarations] std::function<double(double)> f_ = [&](double x){ return f(x);};*

我不明白,因为我的阴谋集团档案里有:

extra-libraries:     stdc++
  ghc-options:         -optcxx-std=c++11
  cxx-options:         -fPIC -std=c++11

我也得到这个错误:

/Users/runner/work/numerical-integration/numerical-integration/cpp/integration.cpp:30:38: error:
     error: expected expression
      std::function<double(double)> f_ = [&](double x) { return f(x); };
                                          ^

有些人建议我不要在previous post中使用lambda函数。但是,我并不精通C/C++,我做了我能做的,只要它能工作,我就很高兴。图书馆工作得很好。但如果我能理解的话,我可以改变一些东西。
在Mac的Cabal文件中有什么特别的事情要做吗?我在谷歌上搜索了“cabal mac c++11”,但什么也没找到。
我试过了,但这并没有改变什么:

if os(darwin)
    cxx-options:       -fPIC -std=gnu++11
  else
    cxx-options:       -fPIC -std=c++11
5sxhfpxr

5sxhfpxr1#

我找到了一个办法这适用于Mac系统与最近足够的ghc(约>=9.4):

library
  hs-source-dirs:      src
  exposed-modules:     Numerical.Integration
  build-depends:       base >= 4.7 && < 5
  if impl(ghc >= 9.4)
    build-depends:     system-cxx-std-lib == 1.0
  elif os(darwin) || os(freebsd)
    extra-libraries:   c++11
  else
    extra-libraries:   stdc++
  other-extensions:    ForeignFunctionInterface
  include-dirs:        cpp
  C-sources:           cpp/integration.cpp
  install-includes:    cpp/ComputeGaussKronrodNodesWeights.h
                     , cpp/Eigen/Cholesky
                     , ............
                     , cpp/Piessens.h  
  default-language:    Haskell2010
  ghc-options:         -Wall
                       -Wcompat
                       -Widentities
                       -Wincomplete-record-updates
                       -Wincomplete-uni-patterns
                       -Wmissing-export-lists
                       -Wmissing-home-modules
                       -Wpartial-fields
                       -Wredundant-constraints
                       -optcxx-std=c++11
  if os(darwin) || os(freebsd)
    ghc-options:       -optcxx-stdlib=libc++

关键成分是包system-cxx-std-lib == 1.0

相关问题