haskell / haskell/c2hs

{#const #} doesn't work for `enum`, only `#define`

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

Description

The `const` feature introduced in #65 isn't working for me; it's simply inserting the C constant name, not its actual `define`d value.

`SndfileExtra.chs`:

``` hs
module SndfileExtra where

import Foreign
import Foreign.C

#include

setVBREncodingQuality :: CInt
setVBREncodingQuality = {#const SFC_SET_VBR_ENCODING_QUALITY #}
```

After `c2hs SndfileExtra.chs`, `SndfileExtra.hs`:

``` hs
-- GENERATED by C->Haskell Compiler, version 0.27.1 Eternal Sunshine, 29 November 2015 (Haskell)
-- Edit the ORIGNAL .chs file instead!

{-# LINE 1 "SndfileExtra.chs" #-}
module SndfileExtra where

import Foreign
import Foreign.C

setVBREncodingQuality :: CInt
setVBREncodingQuality = SFC_SET_VBR_ENCODING_QUALITY
{-# LINE 9 "SndfileExtra.chs" #-}
```

Which of course leads to a GHC error that `SFC_SET_VBR_ENCODING_QUALITY` isn't defined.

(Also, I'm just now noticing the typo in `ORIGNAL`.)

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.