roxen.lists.pike.general

Subject Author Date
Re: c modules Yvan Vander Sanden <yvan[at]youngmusic[dot]org> 28-08-2009
Thanks. That nearly works. I started from the hello world sample (found on
the website) and added some things:

- the includes should be:
#include "pike/global.h" instead of #include "global.h" and so on.

the file module_magic.h seems to be deprecated. I erased it and added

PIKE_MODULE_INIT {
  INIT;
}

PIKE_MODULE_EXIT {
  EXIT;
}

to the end of the example.

The makefile marcus suggests above is almost right, but 'pike -x cflags'
does not produce double quotes around the path, so it doesn't work with a
normal windows install. Just made the include directly:

OBJS=hello.o

PIKE?=pike
CFLAGS+=-fPIC -shared -I"C:/Program Files/Pike/include"
LDFLAGS+=-bundle -bind_at_load -flat_namespace -undefined suppress
CC=gcc

all: hello.so

hello.so: $(OBJS)
    $(LD) $(LDFLAGS) -o $@ $<

hello.o: hello.c

hello.c: hello.cmod
    $(PIKE) -x precompile $< > $@

(for reference: there should be tabs in the beginning of some lines, not
spaces!)

after running make, i get this result:

<LOGOS[at]HAN> ~/Desktop/pike/test
$ make
pike -x precompile hello.cmod > hello.c
gcc -fPIC -shared -I"C:/Program Files/Pike/include"   -c -o hello.o hello.c
hello.c:1: warning: -fPIC ignored for target (all code is position
independent)
hello.cmod:10: error: syntax error before "struct"
hello.cmod:13: error: syntax error before "ptrdiff_t"
hello.cmod:14: error: syntax error before "void"
hello.cmod: In function `f_World_English':
hello.cmod:11: warning: passing arg 1 of `debug_make_shared_string' from
incompatible pointer type
hello.cmod: At top level:
hello.cmod:16: error: syntax error before "ptrdiff_t"
hello.cmod:17: error: syntax error before "void"
hello.cmod: In function `f_World_Swedish':
hello.cmod:17: warning: passing arg 1 of `debug_make_shared_string' from
incompatible pointer type
hello.cmod: At top level:
hello.cmod:21: error: syntax error before '{' token
hello.cmod:19: error: redefinition of 'f_World_English_fun_num'
hello.cmod:13: error: previous definition of 'f_World_English_fun_num' was
here
hello.cmod:8: error: initializer element is not constant
hello.cmod:8: warning: data definition has no type or storage class
hello.cmod:13: error: redefinition of 'f_World_Swedish_fun_num'
hello.cmod:16: error: previous definition of 'f_World_Swedish_fun_num' was
here
hello.cmod:14: error: initializer element is not constant
hello.cmod:14: warning: data definition has no type or storage class
hello.cmod:7: error: conflicting types for 'World_program'
hello.cmod:10: error: previous definition of 'World_program' was here
hello.cmod:7: warning: initialization makes integer from pointer without a
cast
hello.cmod:7: error: initializer element is not constant
hello.cmod:7: warning: data definition has no type or storage class
hello.cmod:7: error: redefinition of 'World_program_fun_num'
hello.cmod:11: error: previous definition of 'World_program_fun_num' was
here
hello.cmod:7: warning: passing arg 2 of `add_program_constant' makes pointer
from integer without a cast
hello.cmod:7: error: initializer element is not constant
hello.cmod:7: warning: data definition has no type or storage class
hello.cmod:23: error: syntax error before '}' token
hello.cmod:25: error: syntax error before '{' token
hello.cmod:7: error: syntax error before "if"
hello.cmod:8: error: redefinition of 'World_program'
hello.cmod:7: error: previous definition of 'World_program' was here
hello.cmod:8: error: redefinition of 'World_program'
hello.cmod:7: error: previous definition of 'World_program' was here
hello.cmod:8: warning: data definition has no type or storage class
hello.cmod:9: error: syntax error before '}' token
make: *** [hello.o] Error 1

I am using MSYS and mingw32, recent versions. Also i'm using the includes
from the latest pike binary for windows. Something is obviously wrong here,
and i doubt it's a typo :-)

Any suggestions?



-- 
Copyright only exists in the imagination of those who do not have any.