This is the second time I face this error:
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
So I am pretty sure this is something that I systematically do wrong. This happens when I wrap some libraries.
My question is what is the right strategy to debug this sort of problem (bearing in mind I have never used gdb). Any particular recommended read?
(Just for the record; I haven't checked if these are already known issues or if they are actually issues or my misuse)
I am playing again with c2nim. I am not sure if this could be a problem:
typedef enum VSColorFamily {
cmGray = 1000000,
cmRGB = 2000000
} VSColorFamily;
typedef enum VSPresetFormat {
pfNone = 0,
pfGray8 = cmGray + 10,
....
gets converted into:
type
VSColorFamily* {.size: sizeof(cint).} = enum
cmGray = 1000000, cmRGB = 2000000
VSPresetFormat* {.size: sizeof(cint).} = enum
pfNone = 0, pfGray8 = cmGray + 10, ...
Shouldn't it be?
pfGray8 = cmGray.int + 10
given that cmGray's type is VSColorFamily.
Additionally, it looks like the ordering of the items is not correct. For example, if you have:
pfGray8 = cmGray + 10,
pfGray16,
pfGrayH,
pfGrayS,
pfYUV420P8 = cmYUV + 10,
it seems like c2nim is not taking into account if pfYUV420P8`is smaller than `pfGray8, because of their values.
The same occurs with the ordering of chars. Nim complains due to the following ordering:
type
enum
ptFunction = 'm',
ptInt = 'i'
Additionally, it looks like:
typedef struct VSMap VSMap;
does not get converted into:
type
VSMap* {.bycopy.} = object
Finally, just to check, from:
(const VSAPI *) getVapourSynthAPI(int version);
I had:
proc getVapourSynthAPI*(version:cint):ptr VSAPI {.importc,dynlib: libName.}
while c2nim produces:
cast[ptr VSAPI](getVapourSynthAPI(int, version))