This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Alexander Asteroth wrote: > > Does gh_list work? > > The following c-source illustrates the problem: > > #include <guile/gh.h> > > void main_prog(int argc, char **argv) { > SCM l1, l2; > l1 = SCM_LIST2(gh_str02scm("filename"), gh_str02scm("bla")); > gh_display(l1); gh_display(gh_str02scm(" is OK"));gh_newline(); > l2 = gh_list(gh_str02scm("filename"), gh_str02scm("bla")); > } > > int main (int argc, char **argv) {gh_enter (argc, argv, main_prog);} > > => > (filename bla) is OK > Segmentation fault > > Did I got somthing wrong on how gh_list should work? > Yes. You need to pass SCM_UNDEFINED as the last argument so gh_list knows how many arguments you passed it (C variadic functions are goofy that way.) In the case of your example: #include <guile/gh.h> void main_prog(int argc, char **argv) { SCM l1, l2; l1 = SCM_LIST2(gh_str02scm("filename"), gh_str02scm("bla")); gh_display(l1); gh_display(gh_str02scm(" is OK"));gh_newline(); l2 = gh_list(gh_str02scm("filename"), gh_str02scm("bla"), SCM_UNDEFINED); /* ^^^^^^^^^^^^^^^ */ } int main (int argc, char **argv) {gh_enter (argc, argv, main_prog);}