#def GLIB_AVAILABLE_IN_ALL
#def G_BEGIN_DECLS
G_BEGIN_DECLS
GLIB_AVAILABLE_IN_ALL
int func1(int i);
void func2(int i);
Generally works fine, but fails when two macros follow each other as above:
stefan@AMD64X2 ~ $ c2nim mups.c home/stefan/mups.c(6, 9) Error: ';' expected
I tried something like
#def GLIB_AVAILABLE_IN_ALL ;
that make c2nim work but inserts nil statements in the output. Is there a better solution available already? And one more note: Some weeks ago c2nim reported error messages with negative line numbers when input file had more than 2^15 lines -- I had to add 2^16 to that value to find the line in text editor. Maybe that is already fixed, I have not tested with latest c2nim and so long input files again.
I have just worked on glib2.40 a bit again... stefan@AMD64X2 ~ $ cat mops.c #define G_E 2.7182818284590452353602874713526624977572470937000 #define G_LN2 0.69314718055994530941723212145817656807550013436026 #define G_LN10 2.3025850929940456840179914546843642076011014886288 #define G_PI 3.1415926535897932384626433832795028841971693993751 #define G_PI_2 1.5707963267948966192313216916397514420985846996876 #define G_PI_4 0.78539816339744830961566084581987572104929234984378 #define G_SQRT2 1.4142135623730950488016887242096980785696718753769 stefan@AMD64X2 ~ $ c2nim mops.c Hint: operation successful (9 lines compiled; 0 sec total; 516.528KB) [SuccessX] stefan@AMD64X2 ~ $ cat mops.nim const G_E* = 3.0 G_LN2* = 1.0 G_LN10* = 2.0 G_PI* = 3.0 G_PI_2* = 2.0 G_PI_4* = 1.0 G_SQRT2* = 1.0 stefan@AMD64X2 ~ $ c2nim -v 0.9.3 Seems that I have still c2nim 0.9.3, while I intalled nimrod 0.9.4 some weeks ago. stefan@AMD64X2 ~ $ nimrod -v Nimrod Compiler Version 0.9.4 (2014-05-20) [Linux: amd64]
May there already exist an improved c2nim?
May there already exist an improved c2nim?
Indeed. c2nim is now available as a babel package!
$ babel update $ babel install c2nim /tmp/babel/c2nim/c2nim.babel -> /home/stefan/.babel/pkgs/c2nim-0.9.6/c2nim.babel Creating symlink: /home/stefan/.babel/pkgs/c2nim-0.9.6/c2nim -> /home/stefan/.babel/bin/c2nim c2nim installed successfully. stefan@AMD64X2 ~ $ c2nim -v 0.9.4 stefan@AMD64X2 ~ $ c2nim mops.c Hint: operation successful (9 lines compiled; 0 sec total; 516.528KB) [SuccessX] stefan@AMD64X2 ~ $ cat mops.nim const G_E* = 2.7182818284590446e+00
Great! I will check if the #def bug is gone also.
Edit: That bug still exists! stefan@AMD64X2 ~ $ cat mups.c #def GLIB_AVAILABLE_IN_ALL #def G_BEGIN_DECLS G_BEGIN_DECLS GLIB_AVAILABLE_IN_ALL int func1(int i); void func2(int i); stefan@AMD64X2 ~ $ c2nim mups.c home/stefan/mups.c(5, 9) Error: ';' expected stefan@AMD64X2 ~ $ c2nim -v 0.9.4