I am trying to wrap ffmpeg. I am having an issue with a C array.

The issue is with the following code 
[libavutil/channel_layout.h](https://github.com/FFmpeg/FFmpeg/blob/release/6.1/libavutil/channel_layout.h#L372-L390).
 I have tried with c2nim, futhark and nimterop without success.

I understand that `AV_CHANNEL_LAYOUT_MASK` creates an array. For example, I 
understand that `AV_CHANNEL_LAYOUT_STEREO`will be `{AV_CHANNEL_ORDER_NATIVE, 2, 
AV_CH_LAYOUT_STEREO, NULL}` where `AV_CH_LAYOUT_STEREO` is 
`(AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT)` so it will be an interger.

I tried something like:
    
    
    {.passL:"-lavutil".}
    
    let AV_CH_FRONT_LEFT 
{.importc:"AV_CH_FRONT_LEFT",header:"libavutil/channel_layout.h".} :cint
    echo AV_CH_FRONT_LEFT  # This works
    
    let AV_CHANNEL_LAYOUT_STEREO {.importc:"AV_CHANNEL_LAYOUT_STEREO", 
header:"libavutil/channel_layout.h".} :ptr UncheckedArray[cint]
    echo AV_CHANNEL_LAYOUT_STEREO[0]  # not working
    
    
    Run

it fails:
    
    
    /@mprueba.nim.c:184:98: error: expected ‘)’ before ‘[’ token
      184 | = dollar___systemZdollars_u8(((NI) 
(AV_CHANNEL_LAYOUT_STEREO[((NI)0)])));
          |                                                             ^
    
    Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3 
-pthread   -I/home/jose/.choosenim/toolchains/nim-2.0.2/lib -I/tmp -o 
/home/jose/.cache/nim/prueba_d/@mprueba.nim.c.o 
/home/jose/.cache/nim/prueba_d/@mprueba.nim.c' failed with exit code: 1
    
    
    
    Run

Any suggestion about how to access 
[AV_CHANNEL_LAYOUT_STEREO](https://github.com/FFmpeg/FFmpeg/blob/1606aab99bd84f0040fb0fa6ccccb092941f01ec/libavutil/channel_layout.h#L383).

Reply via email to