Skip to content
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

Sundials Types Part I #71

Open
idontgetoutmuch opened this issue Mar 11, 2018 · 5 comments
Open

Sundials Types Part I #71

idontgetoutmuch opened this issue Mar 11, 2018 · 5 comments
Labels

Comments

@idontgetoutmuch
Copy link

I am trying to use sundials via inline-c. I am starting to define the types some of which are quite complex :( Even the simplest seems to throw up problems. For example what should I do here?

#if defined(SUNDIALS_INT64_T)

#if __STDC_VERSION__ >= 199901L
typedef int64_t sunindextype;
#else
typedef long int sunindextype;
#endif

#elif defined(SUNDIALS_INT32_T)

#if __STDC_VERSION__ >= 199901L
typedef int32_t sunindextype;
#else
typedef int sunindextype;
#endif

#endif

At the moment I have this

-- This is a lie!!!
type SunIndexType = CLong

sunTypesTable :: Map.Map CT.TypeSpecifier TH.TypeQ
sunTypesTable = Map.fromList
  [
    (CT.TypeName "sunindextype", [t| SunIndexType |] )
  ]

sunctx = mempty {ctxTypesTable = sunTypesTable}
@idontgetoutmuch
Copy link
Author

Ah but maybe I don't need to do this anyway.

@stites
Copy link

stites commented Nov 13, 2018

@idontgetoutmuch how did you resolve this?

@idontgetoutmuch
Copy link
Author

I don't think I did resolve that particular issue but it's all working - see here: https://github.com/haskell-numerics/hmatrix-sundials/blob/master/src/Numeric/Sundials/Arkode.hsc

@ekmett
Copy link
Contributor

ekmett commented Jun 3, 2019

My best work around for this sort of issue is to use hsc2hs and inline-c in the same Haskell module.

With hsc2hs you can use

type SunIndexType = #type sunindextype

and then the rest of your code is correct.

@idontgetoutmuch
Copy link
Author

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants