-
Notifications
You must be signed in to change notification settings - Fork 49
Can't use function pointers in C++11 code #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I realise |
After finding these related issues:
I tried building the source inside a docker container and it worked. The OSX compiler is more picky about what it allows. |
I can work around this with the custom Setup.hs below. Unfortunately import Distribution.Simple
import Distribution.Simple.Setup
import Distribution.Types.HookedBuildInfo
import Distribution.PackageDescription
import Distribution.Simple.LocalBuildInfo
import Data.List (dropWhile)
main = defaultMainWithHooks simpleUserHooks { buildHook = myBuildHook
}
BuildHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO ()
myBuildHook desc info hooks flags = (buildHook simpleUserHooks) (fixDescription desc) info hooks flags
-- Fix a PackageDescription to remove the -optc-std=c++11 option
fixDescription desc = desc { library = fmap fixLibrary (library desc) } where
fixLibrary lib = lib { libBuildInfo = fixBuildInfo (libBuildInfo lib) }
fixBuildInfo info = info { options = fixOptions (options info) }
fixOptions options = fmap fixOption options
fixOption (flavor, args) = (flavor, dropWhile ((==) "-optc-std=c++11") args) |
It's going to be a bit easier in GHC 8.8: https://gitlab.haskell.org/ghc/ghc/issues/16477 |
I can't get inline-c-cpp to compile if I use the
funCtx
to try and call Haskell from C++. The problem seems to be I can't specify exactly when to use the "-std=c++11" switch in Cabal.Below is a minimal file which exposes the problem. My system is:
src/Lib.hs
package.yaml
If I compile without -std=c++11 I get
error: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
If I compile with -std=c++11 I get
Strangely
someFunc2
will compile in either case.The text was updated successfully, but these errors were encountered: