haskell / c2hs

c2hs is a pre-processor for Haskell FFI bindings to C libraries
http://hackage.haskell.org/package/c2hs
Other
197 stars 50 forks source link

{#sizeof#} returns incorrect value #175

Open centromere opened 7 years ago

centromere commented 7 years ago

I'm using this include file and the following Haskell source:

module Test where

#include "nfc-types.h"

{#sizeof nfc_iso14443a_info#}

The output of c2hs is:

-- GENERATED by C->Haskell Compiler, version 0.28.1 Switcheroo, 1 April 2016 (Haskell)
-- Edit the ORIGNAL .chs file instead!

{-# LINE 1 "test.chs" #-}
module Test where

296
{-# LINE 5 "test.chs" #-}

But when I compile the following program:

#include <stdio.h>

#include "nfc/nfc-types.h"

int main() {
  printf("%lu\n", sizeof(nfc_iso14443a_info));
  return 0;
}

The output is:

$ ./a.out 
283
ian-ross commented 7 years ago

Probably a duplicate of #172, since that header uses #pragma pack.