haskell / haskell/c2hs

Cannot create #fun of typedef functions

Open
#142 4 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Haskell
Stars
211
Forks
52
PR merge metrics
No merged PRs in 30d

Description

I have the following typedef: `typedef const char* fmi2GetTypesPlatformTYPE(void);`
And the following function: `__declspec(dllexport) fmi2GetTypesPlatformTYPE fmi2GetTypesPlatform;`

I have tried `{#fun unsafe fmi2GetTypesPlatform as ^ {} -> `String' #}` but this gives me
fmi2Functions.chs:5: (column 14) [ERROR] >>> Function expected!
A function is needed here, but this declarator does not declare
a function.

I have also tried mapping the typedef first with
`type Fmi2GetTypesPlatformTYPE = {#type fmi2GetTypesPlatformTYPE#}`
but with the same result.

Is typedef functions not supported by C2HS? If so, then this is a feature request

Another option is to define/use types inside a #type and marshallers. E.g. mapping the function
`typedef fmi2Status fmi2SetupExperimentTYPE (fmi2Component, fmi2Boolean, fmi2Real, fmi2Real, fmi2Boolean, fmi2Real);` with
`type Fmi2SetupExperimentTYPE = {#type fmi2SetupExperimentTYPE#}`
gives the result:
`type Fmi2SetupExperimentTYPE = (((fmi2Component) -> (CInt -> (CDouble -> (CDouble -> (CInt -> (CDouble -> (IO CInt))))))))`

I have defined fmi2Boolean as `type Fmi2Boolean = {#type fmi2Boolean#}` and therefore it would be nice if this type was used instaed of CInt

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.