I have some Github actions for my library 'numerical-integration'. They all work fine except those on Mac. Among the warnings and error messages for Mac, there are:
note: expanded from macro '_LIBCPP_DEPRECATED_CXX03_FUNCTION' attribute((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
warning: 'function<double (double)>' is deprecated: Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type [-Wdeprecated-declarations] std::function<double(double)> f_ = [&](double x) { return f(x); };
I don't understand since I have in my cabal file:
extra-libraries: stdc++
ghc-options: -optcxx-std=c++11
cxx-options: -fPIC -std=c++11
I also get this error:
/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); };
^
Some of you recommend me to not use a lambda function in my previous post. But again, I'm not fluent in C/C++ and I do what I can, and I'm happy as long as it works... And the library works very well. But I'm ok for changing something if I understand.
Is there something special to do in the Cabal file for Mac ? I googled "cabal mac c++11" but I found nothing.
I tried this but that does not change anything:
if os(darwin)
cxx-options: -fPIC -std=gnu++11
else
cxx-options: -fPIC -std=c++11
I've found a way. This works for Mac systems with a recent enough ghc (about >=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++
The key ingredient is the package system-cxx-std-lib == 1.0.